Sass 颜色变量在 darken() 中不起作用 [英] Sass color variable not working inside darken()

查看:41
本文介绍了Sass 颜色变量在 darken() 中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有颜色列表,我想像这样对它们使用 darken():

I've got list of colors and I would like to use darken() on them like so:

$innerPagesBgColors: "#6B46C1", "#2980B9", "#FD5456", "#000";

.foo {
    color: darken(nth($innerPagesBgColors, 3), 5%);
}

但我收到此错误:

$color: "#FD5456" 不是‘变暗’的颜色

$color: "#FD5456" is not a color for `darken'

我尝试插入 nth() 部分,但这也无济于事.

I tried interpolating the nth() portion but that didn't help either.

推荐答案

问题是,darken 函数需要一个颜色作为第一个参数,相反,你试图传递一个字符串.

The problem is that darken function requires a color as first argument and, instead, you're trying to pass a string.

type-of(#6B46C1); // returns color
type-of("#6B46C1"); // returns string

所以你应该删除 $innerPagesBgColors 中的所有引号:

So you should remove all quotes in $innerPagesBgColors:

$innerPagesBgColors: #6B46C1, #2980B9, #FD5456, #000;

这篇关于Sass 颜色变量在 darken() 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆