我正在检查codecademy.com站点,并且有一个具有以下属性的元素:
box-shadow: inset 0 0 5px rgb(0 0 0 / 15%), 0 0 7px #fff;
Run Code Online (Sandbox Code Playgroud)
看起来这会导致元素周围出现双圈,内圈是白色的,外圈是透明的。
但是,当我尝试在样式表中使用此代码时,出现以下错误:
Error: Function rgb is missing argument $green.
on line 1260 of common.scss
>> box-shadow: inset 0 0 5px rgb(0 0 0 / 15%), 0 0 7px #fff;
------------------------------------------^
Run Code Online (Sandbox Code Playgroud)
不确定此错误是关于什么或如何解决它。有任何想法吗?
小智 9
正如 Dan Mulin 所说,sass 还没有赶上新标准,所以不要box-shadow: inset 0 0 5px rgb(0 0 0 / 15%)使用box-shadow: inset 0 0 5px rgba(0, 0, 0 , 0.15)
Regards
The new standard is to use three values without commas followed by a slash and the opacity as a percentage. Which looks like this:
/* New Standard for color using rgb (rgba depreacated) */
rgb(0 0 0 / 0%)
/* Old standard for color using rgb and rgba */
rgb(0, 0, 0)
rgba(0, 0, 0, 0)
Run Code Online (Sandbox Code Playgroud)
Sass hasn't caught up to the standard, so you'll get a compilation error when you try to use the new format.
You can learn more here: https://drafts.csswg.org/css-color/#rgb-functions
小智 8
我发现这个错误是因为 node sass 弃用警告我必须将 node-sass 卸载到 sass 才能修复它。我按照以下步骤操作:
//使用此命令安装 sass,因为 node-sass 已弃用。
人们会想,为什么这是根本原因呢?大多数问题来自于样式,人们建议将 rgb 更改为 rgba 等,这是处理解决方案的一种方法,但我有一种顺风样式,它被导入到从 node_modules 中提取的样式中。因此,对于永久解决方案,我相信这就像一个魅力