所以我有一个问题,将第 n 个元素隐藏在没有 id 但其父 div 有一个 ID 的 div 中。我想隐藏显示“第二个”的第二个跨度
<div id="example">
<div>
<span>First</span>
<span>Second</span>
</div>
</div>
是的,您可以使用:nth-child()
属性将 nth-child 值更改为要隐藏的跨度 - 在这种情况下,2 是第二个跨度
#example span:nth-child(2) {
display: none;
}
<div id="example">
<div>
<span>First</span>
<span>Second</span>
</div>
</div>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句