CSS 中的变量
cssweb developmentfront end technology更新于 2024/8/23 6:04:17
CSS 中的变量用于向网页添加自定义属性值。设置属性的自定义名称并设置其值。
您可以尝试运行以下代码,在 CSS 中实现变量来更改背景和文本颜色
示例
<!DOCTYPE html>
<html>
<head>
<style>
:root {
--my-bg-color: blue;
--my-color: white;
}
#demo {
background-color: var(--my-bg-color);
color: var(--my-color);
}
</style>
</head>
<body>
<h1>Heading One</h1>
<div id = "demo">This is demo text. This is demo text. This is demo text.
This is demo text. This is demo text. This is demo text. This is demo text.
This is demo text. This is demo text.
</div>
<br>
</body>
</html>
相关文章
有用资源
css 参考教程 - 该教程包含有关 css 的更多信息:https://www.cainiaomax.com/css/

