Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

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

如何拼接css变量

如--co1为 #ff3366, 这个值是后台设置的, 有且仅有一个全局颜色
这样使用没问题: background: var(--co1)

现在有一个块要设置半透明: #ff336655 怎么设置呢(不能用js)

background: var(--co1)"55" //无效
background: calc(var(--co1)"55") //无效


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

1 Answer

0 votes
by (71.8m points)
<html>

<head>

<title>option chain</title>

<meta charset="utf-8" />

<style>

body {

--x: 255, 0 ,0;

}

div {

height: 100px;

}

div:nth-of-type(1) {

background-color: rgb(var(--x));

}

div:nth-of-type(2) {

background-color: rgba(var(--x), .5);

}

</style>

</head>

<body>

<div></div>

<div></div>

</body>

</html>

ff336655 是有效的颜色值?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...