【问题标题】:What does the @import mean in sass when it has a property and brackets after it?当 @import 后面有一个属性和括号时,它在 sass 中是什么意思?
【发布时间】:2015-04-15 14:40:24
【问题描述】:

我正在尝试解码以下行...

@include button-size($padding-base-vertical, $padding-base-horizontal, $font-size-base, $line-height-base, $border-radius-base);

有人知道是什么意思吗?

我不明白函数表达式构造是什么,是mixin还是什么?

【问题讨论】:

  • @import 还是@include?​​span>
  • 你看文档了吗?说真的,它只有一页长。你会在 2 秒内得到答案。
  • 请启发我,那么这个“文档”在哪里?来吧……拿出来……

标签: css sass


【解决方案1】:

我不认为导入可以传递变量,因此我假设您的意思是包含。假设我们有以下 mixin:

@mixin rotate($degrees: 90deg) {
  transform: rotate($degrees);
}

你可以在没有变量的情况下包含它;然后使用默认的“90deg”,但您可以通过在包含中传递参数来覆盖它。要更改这一点,您可以直接传递一个值,也可以像在示例中那样传递一个变量。有效的是:

@include rotate(90deg);
@include rotate;

$half: 180deg;
@include rotate($half);

对于多个参数,还可以定义要覆盖的参数:

@mixin base-font($fontWeight: normal, $fontColor: $mineShaft) {
  color: $fontColor;
  font-weight: $fontWeight;
}

@include base-font($fontColor: $myColor)

【讨论】:

    猜你喜欢
    • 2019-02-23
    • 1970-01-01
    • 2018-11-02
    • 2018-10-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-16
    相关资源
    最近更新 更多