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; }
相关推荐
CappuccinoRose16 小时前
前端开发交互体系 - 汇总篇
开发语言·前端·javascript·css·html·交互
inksci2 天前
用飞帆做了个小网页
前端·javascript·css·html
星云_byto3 天前
CSS面试题
前端·css
科研邪修法3 天前
PDF新增页面文字与文本批注怎么区分?以双版本培训讲义为例
前端·css·pdf
狮子座的男孩4 天前
html+css基础:31、响应式布局(媒体类型,媒体特性,运算符,常用阈值)
前端·css·经验分享·html·响应式布局·媒体类型/特性·常用阈值
狮子座的男孩4 天前
html+css基础:32、BFC(父子元素防止 margin 塌陷,父子元素清除浮动,兄弟元素两栏布局)
前端·css·经验分享·html·bfc·margin塌陷·清除浮动
吴长建先生4 天前
Flutter IM 即时聊天应用开发:从 0 到 1 实
css
htzyl2065 天前
前端样式-弹窗淡入淡出,为什么你的 `transition` 一直不生效
前端·css·html
Brookty5 天前
CSS基础知识(二):盒模型、内外边距、外边距折叠与父子元素的布局关系
前端·css
Mh6 天前
我是如何设计品牌站组件库的?
前端·css·设计模式