简体   繁体   English

如何使用 Saas 变量颜色主题混合为背景颜色赋予不透明度?

[英]How to give opacity to background-color using Saas variables color themes mixins?

This is my mixins for themes color这是我的主题颜色混合

$themes: (
    light: (
    black-color: black,
    ),
    dark: (
        black-color: rgb(235, 13, 161),
    )
);

 @mixin themify($themes) {
    @each $theme, $map in $themes {
      .theme-#{$theme} & {
        $theme-map: () !global;
        @each $key, $submap in $map {
          $value: map-get(map-get($themes, $theme), '#{$key}');
          $theme-map: map-merge($theme-map, ($key: $value)) !global;
        }
        @content;
        $theme-map: null !global;
      }
    }
  }

  @function themed($key) {
    @return map-get($theme-map, $key);
  }

This is my class where i am appending property with variables这是我的 class 我在其中附加属性和变量

.overlay {
     @include themify($themes) {
        background-color: themed(black-color, .5);
        box-shadow: 1px 1px 1px  themed(black-color, .5);
    }
}

But opacity not working and following error getting Sass Error: Only 1 argument allowed, but 2 were passed.但不透明度不起作用,并出现以下错误,获取 Sass 错误:只允许 1 个参数,但传递了 2 个。

If you don't use the black-color anywhere else you could try redefining them as:如果您不在其他任何地方使用黑色,您可以尝试将它们重新定义为:

$themes: (
    light: (
    black-color: rgba(0, 0, 0, 0.5),
    ),
    dark: (
        black-color: rgba(235, 13, 161, 0.5),
    )
);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM