选择父级是最后一个子级的班级

问题描述 投票:0回答:1
html css sass css-selectors
1个回答
0
投票

:last-child > .custom-class
应该执行您所要求的操作:如果它是最后一个子元素的直接子元素,则选择
custom-class

:last-child > .custom-class {
  color: green;
}
<div>
  <div>
    <div class="custom-class">whatever</div>
  </div>
  <div>
    <div class="custom-class">whatever</div>
  </div>
  <div>
    <div class="custom-class">thing i want to select</div>
  </div>
</div>

© www.soinside.com 2019 - 2024. All rights reserved.