【问题标题】:SASS mixin using SASS rgba() function not working with interpolation使用 SASS rgba() 函数的 SASS mixin 不适用于插值
【发布时间】:2017-03-11 02:34:07
【问题描述】:

SASS 文档说rgba 函数可以通过两种方式调用。

我创建了一个codepen 来演示我遇到问题的mixin 中的rgba 函数:

$hd-color1: #366dbd;    // heading color
$hd-shadow1: 0.24;      // text shadow opacity

@mixin ColorAndTextShadow($color, $opacity) {
  color: $color;
  text-shadow: 3px 1px rgba( #{$color}, #{$opacity} );
}

h2 {
  @include ColorAndTextShadow ( #{$hd-color1}, #{$hd-shadow1} );
  font-family: Circular, Helvetica, Arial, sans-serif;
  font-size: 50px;
  font-weight: bold;
  text-transform: uppercase;
}

提前感谢您查看

【问题讨论】:

    标签: sass rgba


    【解决方案1】:

    我相信这只是一个语法错误。可以直接传入变量。

    请看codepen

    $hd-color1: #366dbd;    // heading color
    $hd-shadow1: 0.24;      // text shadow opacity
    
    @mixin ColorAndTextShadow($color, $opacity) {
      color: $color;
      text-shadow: 3px 1px rgba($color, $opacity );
    }
    
    h2 {
      @include ColorAndTextShadow ( $hd-color1, $hd-shadow1 );
      font-family: Circular, Helvetica, Arial, sans-serif;
      font-size: 50px;
      font-weight: bold;
      text-transform: uppercase;
    }
    

    【讨论】:

    • 那行得通。我在较早的尝试中从 mixin 中删除了插值,但没有从 @include 中删除。谢谢。
    猜你喜欢
    • 2014-08-11
    • 2013-02-10
    • 2013-04-15
    • 1970-01-01
    • 2016-12-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多