【问题标题】:SASS Rainbow Background simplifiedSASS 彩虹背景简化
【发布时间】:2018-05-08 13:11:35
【问题描述】:

有没有办法可以将它压缩得更多,所以我需要在这一行中添加:

background: linear-gradient(left, $rainbow-colors);

我需要在这里嵌套一些东西吗?

@mixin rainbow($colors...) {
    @each $color in $colors {
      .#{$color} {
            background: $color; } 
    }
  }
$rainbow-red: red;
$rainbow-orange: orange;
$rainbow-yellow: yellow;
$rainbow-green: green;
$rainbow-blue: blue;

body {
  background: -webkit-linear-gradient(left, $rainbow-red, $rainbow-orange, $rainbow-yellow, $rainbow-green, $rainbow-blue);
}

【问题讨论】:

    标签: css sass rainbows


    【解决方案1】:

    您不必将每种颜色指定为自己的变量。一个逗号分隔的列表就足够了。 (另外,你的代码应该写成to left,而不仅仅是left。)

    body {
      $rainbow-colors: red, orange, yellow, green, blue;
      background: linear-gradient(to left, $rainbow-colors);
    }
    

    【讨论】:

      猜你喜欢
      • 2017-11-22
      • 2021-02-27
      • 2019-08-02
      • 1970-01-01
      • 2021-05-10
      • 2010-11-15
      • 2015-02-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多