我想知道是否可以使用 CSS nth-child 选择器选择第 4 个元素之后的每个偶数元素。
下面是我到目前为止所拥有的?任何想法
scss
.project{
@include span-columns(4 of 8);
@include omega(2n);
height: 580px;
border: 1px solid black;
&:first-child{
margin-top: 55px;
}
&:nth-child(n+4){
margin-top: -50px;
}
}
最佳答案
为了在第四个元素之后选择第二个元素,您正在寻找 :nth-child(2n+6)
:)
div:nth-child(2n+6) {
color: red;
}
<div>Test</div>
<div>Test</div>
<div>Test</div>
<div>Test</div>
<div>Test</div>
<div>Test</div>
<div>Test</div>
<div>Test</div>
<div>Test</div>
希望对您有所帮助! :)
关于html - 选择 4 之后的每个偶数项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42540984/