<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
:root{
--c:blue;
}
.box{
--b:red;
color: var(--b);
background: var(--c);
}
</style>
</head>
<body>
<div class="box">
2222222222
</div>
</body>
<script>
document.getElementsByClassName('box')[0].style.setProperty('--b','green')
</script>
</html>
css变量声明,js操作css变量
最新推荐文章于 2024-02-22 15:03:23 发布