【问题标题】:SASS function/mixins for property value属性值的 SASS 函数/mixins
【发布时间】:2012-02-14 15:34:41
【问题描述】:

这是一个混合的示例:

=border($alpha: 0.2)
    1px solid hsla(0, 0, 0, $alpha)

我想使用函数/mixins 来实现这样的目标:

border-right: +border(0.2)

这将编译成:

border-right: 1px solid hsla(0, 0, 0, 0.2)

我还没有看到任何关于如何使用函数/mixin 来动态计算属性值的文档。我只看到它们也包含该属性时使用。这是如何实现的?

【问题讨论】:

标签: css sass compass-sass


【解决方案1】:

你可以这样写函数:

@function border($alpha: 0.2)
  $border: 1px solid hsla(0, 0, 0, $alpha)
  @return $border

并像任何其他 sass/compass 函数一样应用它们:

border-right: border(0.2)

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-20
  • 1970-01-01
  • 2019-04-20
  • 2020-05-29
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多