【问题标题】:Use !important Keyword In Sass Maps在 Sass 映射中使用 !important 关键字
【发布时间】:2017-02-05 08:43:15
【问题描述】:

我正在使用一个名为 typi (https://github.com/zellwk/typi) 的 sass mixin 库,现在如何在 sass 映射函数中使用 !important 关键字,这是我尝试实现的示例

$i:!important;
$heading:(
null:( 80px,80px $i),
large:(60px,60px $i),
small:(40px,40px $i)
);

我正在尝试在键值中使用 !important 关键字,例如 空:(80px $i,80px $i)

每当我使用关键字时,我都会在编译时收到此错误

" error sass/style.scss (第 30 行 sass/typi/scss/ty/_functions.scss: $number: "80px!important" is not a number for `unitless') "

【问题讨论】:

  • 如果你使用适当的特异性,你不应该需要一个 !important
  • 我同意,尽管在某些情况下您也必须使用 !important :)
  • 您不能将!important 传递给函数。因为它只需要一个数字,而不是 css 属性值。

标签: css sass mixins


【解决方案1】:

作为映射,您需要在调用中添加!important,而不是在地图上,所以它看起来像:

@include typi($heading, !important);

这不是一个好习惯,但有时当您在 SASS 上使用继承时,您需要它。正确的语法是这个。

希望这会有所帮助:)

【讨论】:

    猜你喜欢
    • 2019-04-05
    • 1970-01-01
    • 1970-01-01
    • 2023-03-16
    • 1970-01-01
    • 1970-01-01
    • 2011-05-29
    • 2018-03-15
    相关资源
    最近更新 更多