【问题标题】:sass function return classsass 函数返回类
【发布时间】:2016-04-04 14:19:13
【问题描述】:

我有这个代码

.npt {
  ul {
    li {
      a {
        background: $red-700 !important;
      }
    }
  }
}

我需要为很多颜色复制这个,但我想传递颜色基础 ($red) 并返回这个对应的 css。 我需要这样的东西

@mixin .npt($blue); -->

.npt {
  ul {
    li {
      a {
        background: $blue-700 !important;
      }
    }
  }
}

我该怎么做? 谢谢

【问题讨论】:

  • 我喜欢随机投票

标签: css function sass mixins


【解决方案1】:

@mixin npt($colorvariable) {
  background: $colorvariable-700 !important;
}

try this one and then include 

@include npt($blue);

【讨论】:

  • 好吧,但是这个mixin只返回背景属性,是否可以返回带有属性的类?像 ul { li { a { 背景:$colorvariable-700 !important; }}}
  • 试试这个@mixin npt($colorvariable) { ul { li { a { background: $colorvariable !important; }}} }
  • 好吧,我已经尝试过这个解决方案,但它不起作用,现在可以了,谢谢
猜你喜欢
  • 2014-02-05
  • 2016-12-11
  • 2016-03-30
  • 1970-01-01
  • 2021-04-17
  • 1970-01-01
  • 1970-01-01
  • 2021-06-02
  • 2016-09-21
相关资源
最近更新 更多