【问题标题】:How to override properties for the last-child of an element如何覆盖元素的最后一个子元素的属性
【发布时间】:2013-01-15 00:35:10
【问题描述】:

我在我构建的页面上有几个部分元素。对于垂直结构,我应用垂直节奏。现在我想实现所有部分的节奏为 0,0,3,2,而最后一个部分应该或多或少地获得重置节奏。

section{    
    @include rhythm(0,0,3,2);
    &:last-child{
        @include rhythm(0,0,0,0);
    }
}

可能是一个基本问题,但不知何故,0,0,3,2 也被应用到最后一个部分,而不是把节奏完全排除在最后一个部分。谢谢!

【问题讨论】:

    标签: compass-sass sass


    【解决方案1】:

    使用the :not() selector:

    section {
        &:not(:last-child) {
            @include rhythm(0,0,3,2);
        }
    
        &:last-child{
            @include rhythm(0,0,0,0);
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2011-09-29
      • 1970-01-01
      • 2014-02-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-31
      • 2020-08-11
      • 1970-01-01
      相关资源
      最近更新 更多