CSS变量

元素背景需要统一,一个个设置修改起来很麻烦,也没有全局变量?

CSS中的变量_css变量-CSDN博客

-- 前缀定义变量,var(--) 使用变量,:root 表示根元素。

css 复制代码
:root { --bg:#222; --fg:#bbb; }
body { background:var(--bg); }
h1, h2, h3, h4 { text-align:center; color:var(--fg); }
p { text-indent:2em; font-size:1.5em;}
img { display:block; margin:0 auto; max-width:100%;}
a { text-decoration:none; color:var(--fg); }
textarea { width:100%; height:4em; background:var(--bg); color:var(--fg); border-radius:5px; }
#content { width:1000px; margin:2em auto; padding:2em; background:var(--bg); border-radius:10px; }
.item { margin:10px; white-space:nowrap; }
.id { display:inline-block; width:20px; height:20px; color:darkgreen; vertical-align:middle; }
.time { width:100px; background:var(--bg); color:var(--fg); border:1px solid gray; text-align:center; }
.footer { color:var(--fg); text-align:center; }
相关推荐
英俊潇洒美少年2 小时前
css中专门用来提升渲染性能、减少重排重绘的属性
前端·css
我是伪码农5 小时前
14届蓝桥杯
javascript·css·css3
是上好佳佳佳呀7 小时前
【前端(二)】CSS 知识梳理:从编写位置到选择器优先级
前端·css
李松桃10 小时前
01HTML-CSS-入门知识点
前端·css
酉鬼女又兒12 小时前
零基础入门前端 第十三届蓝桥杯省赛 :水果拼盘 Flex一篇过(可用于备赛蓝桥杯Web应用开发)
前端·css·职场和发展·蓝桥杯·css3
whuhewei1 天前
在React中实现CSS动画的回放
前端·css·react.js
敏编程1 天前
一天一个Python库:soupsieve - CSS 选择器在 Beautiful Soup 中的力量
开发语言·css·python
圣光SG1 天前
奶茶店网页(纯HTML和CSS)
前端·css·html
kyriewen1 天前
你还在给每个图片父元素加类名?CSS :has() 让选择器“逆天改命”
前端·css·面试
reasonsummer1 天前
【白板类-02-01】20260326找影子01(html+希沃白板)
css·html·css3