【问题标题】:SASS Mixin Arguments with specific values具有特定值的 SASS Mixin 参数
【发布时间】:2018-10-29 17:14:06
【问题描述】:

有什么方法可以检查 mixins 中的参数。 例如,我有一个 shadow mixin,并且想以不同的方式包含它(调用它)以防它的参数。

@mixin 阴影($shadow, $position, $color) { ...... }

如果我通过 Top2 它应该只改变第一个参数

.box { @include shadow(inset, Top2, #000); } => `box-shadow: inset, 2px 0 0 0, #000`

如果我通过 Bottom2 它应该将参数更改为 -2px

.box { @include shadow(inset, Bottom2, #000); } => `box-shadow: inset, -2px 0 0 0, #000`

【问题讨论】:

  • 我不这么认为,mixin 是一个可重用的 css 块 sass-lang.com/documentation/…
  • 我不确定你到底想要什么?你能告诉我们你的 mixin 吗?

标签: css sass


【解决方案1】:

我认为你应该使用这种类型。

    @mixin box-shadow($values) {
-webkit-box-shadow: $values;
-moz-box-shadow: $values; 
box-shadow: $values;
}
    @mixin box-shadow-inset($inset) {
-webkit-box-shadow: $inset;
-moz-box-shadow: $inset;
      box-shadow: $inset;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-04-23
    • 2017-06-20
    • 2021-11-21
    • 2015-05-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-28
    相关资源
    最近更新 更多