Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.3k views
in Technique[技术] by (71.8m points)

css 怎样获取变量的值

.scss文件

:root{
    --custom-color: #ff0000;
}

.bg-color {
    background-color: rgba(var(--custom-color), .5); //无效果
    background-color: lighten(var(--custom-color), 10%); //报错
}

定义了一个颜色变量,然后想在CSS类中应用改变颜色的值(#ff0000),在不依靠js或其它编程语言怎样可以实现?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

我猜你说的是CSS的变量,而不是SASS的变量,可以看下 张鑫旭大佬的文章,一目了然


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...