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; }
相关推荐
之歆6 小时前
DAY08_CSS浮动与行内块布局实战指南(下)
前端·css
yqcoder6 小时前
CSS Position 全解析:5 种定位模式详解
前端·css
之歆7 小时前
DAY08_CSS浮动与行内块布局实战指南(上)
前端·css
yqcoder13 小时前
端经典面试题:为什么 0.1 + 0.2 !== 0.3?
前端·css
ZC跨境爬虫14 小时前
跟着 MDN 学 HTML day_12:(HTML网页图片嵌入)
前端·javascript·css·ui·html
用户0595401744614 小时前
大模型记忆存储踩坑实录:LangChain 的 ConversationBufferMemory 让我排查了 6 小时
前端·css
剑神一笑17 小时前
CSS Animation Timeline 可视化动画编辑器:从关键帧到流畅动画
前端·css·编辑器
2401_8784545317 小时前
HTML和CSS的复习2
前端·css·html
We་ct17 小时前
吃透现代CSS全技术体系
前端·css·css3·sass·postcss·预处理器
ZC跨境爬虫17 小时前
跟着 MDN 学 HTML day_11:(语义化容器全站重构+独立CSS拆分+字体合规引入)
前端·css·ui·重构·html·edge浏览器