【问题标题】:Converting LESS Mixins with !important to SCSS将带有 !important 的 LESS Mixins 转换为 SCSS
【发布时间】:2015-02-12 20:58:13
【问题描述】:

我是 SCSS 新手,但在转换此 LESS 代码时遇到了问题。

较少

.white {background: #fff} 

.color {.white() !important}

生产

.white {background: #fff}

.color {background: #fff !important}

我正在尝试复制 SCSS 中的行为,但到目前为止,我所有的尝试都遇到了语法错误。

我在谷歌搜索中得到的最好的结果是:Adding !important using a Compass Mixin,然而,它似乎只适用于有参数的 mixin。我的类/mixin 没有。

【问题讨论】:

    标签: css sass less


    【解决方案1】:

    你可以试试placeholder selectors:

    %white{
        background: #fff !important;
    }
    
    .color{
        @extend %white;
    }
    

    它可能不是 mixin,但 %white 在扩展之前不会被添加到 CSS 中。

    【讨论】:

      猜你喜欢
      • 2017-02-07
      • 2018-06-25
      • 2014-12-18
      • 2017-11-29
      • 1970-01-01
      • 1970-01-01
      • 2017-05-26
      • 1970-01-01
      • 2013-05-10
      相关资源
      最近更新 更多