作者:fo切為祢 | 来源:互联网 | 2023-05-18 12:27
Iwanttoskipcountingonanelementinnth-childwith:notattribute,butitdoesnotworkorits
I want to skip counting on an element in nth-child with :not attribute, but it does not work or it's not even possible to do. Is there any other way to do this?
我想跳过对nth-child中的元素的依赖:not attribute,但它不起作用或者甚至不可能。有没有其他方法可以做到这一点?
Here is the code:
这是代码:
.layout {
float: left;
width: 100px;
height: 60px;
border: 2px solid red;
margin-right: 10px;
margin-bottom: 10px;
}
.hidden {
display: none;
}
.layout:not(.hidden):nth-child(2n+1) {
clear: both;
}
Even though the element with class .hidden is not visible, it's still counted with nth-child
即使具有类.hidden的元素不可见,它仍然与nth-child一起计算
2 个解决方案