【问题标题】:Using mixin with multiple class selector将 mixin 与多个类选择器一起使用
【发布时间】:2013-12-04 22:41:18
【问题描述】:

我有这样的混合:

@mixin box($bgcolor:#ff00ff){
    .box{
        .inner{
            border: 1px;
               background-color:$bgcolor;
        }
    }
}

我怎么能这样使用smth

    @include box();
    blue &{
        @include box(blue);
    }

为了实现:

    .box .inner{
    ...       
    }
    .blue.box{
    ...       
    }

【问题讨论】:

    标签: sass compass-sass


    【解决方案1】:

    你需要一个mixin吗?试试这样的:

    .box {
      .inner, &.blue {
        border: 1px;
        background-color:$bgcolor;
      }
    }
    

    特别是如果您只想在其中一个上使用 inner 类。

    【讨论】:

    • 是的。我需要一个mixin。假设这是一个按钮的mixin。结构比较复杂,有10多个参数,我需要有不同的“外观”:class="dark btn" class="happy btn" class="dropbox btn"
    猜你喜欢
    • 2015-05-09
    • 2011-10-30
    • 2021-09-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-25
    • 2021-01-22
    相关资源
    最近更新 更多