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; }
相关推荐
@@小旭12 小时前
实现头部Sticky 粘性布局,并且点击菜单滑动到相应位置
前端·javascript·css
Irene199113 小时前
CSS 定位属性(relative、absolute、fixed、sticky)与实用技巧总结
css
我的写法有点潮17 小时前
推荐几个国外比较流行的UI库(上)
前端·javascript·css
m0_5027249518 小时前
vue动态设置背景图片后显示异常
前端·css
@Autowire19 小时前
Layout-position
前端·css
神秘的猪头19 小时前
🎨 CSS 这种“烂大街”的技术,怎么在 React 和 Vue 里玩出花来?—— 模块化 CSS 深度避坑指南
css·vue.js·react.js
3秒一个大21 小时前
模块化 CSS:解决样式污染的前端工程化方案
css·vue.js·react.js
kilito_011 天前
数字时钟翻页效果
javascript·css·css3
霍理迪1 天前
CSS布局方式——弹性盒子(flex)
前端·css
研☆香1 天前
html css js文件开发规范
javascript·css·html