html - 选择 4 之后的每个偶数项

标签 html css sass css-selectors

我想知道是否可以使用 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/

相关文章:

java - 在 GWT 中,如何使用 <ui :style> or ClientBundle 覆盖 DisclosurePanel 的 CSS

css - 未加载自定义图标字体

html - 无法打印 Ionic 3 页的全部内容

html - 如何使用 Bootstrap 以相同的高度水平显示两张卡片

html - 为什么我的 HTML 文本区域中有一个空白,而我的文本区域中有占位符?

css - Gulp-sass 无法编译

javascript - SASS mixin 将十六进制转换为 CSS 过滤器

html - Excel 到 HTML 表格

css - 按百分比在 React Native 中创建圆圈?

html - Padding-right 太大