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; }
相关推荐
用户0595401744615 小时前
LangChain Memory 踩坑实录:10种异常场景差点搞崩生产,我们写了一套自动化测试保命
前端·css
用户059540174461 天前
Redis缓存回滚踩坑实录:一个配置失误,让我在凌晨3点丢了3000条数据
前端·css
এ慕ོ冬℘゜2 天前
纯 CSS 实现自定义 Switch 开关(商品上下架滑块)
前端·css
并不喜欢吃鱼2 天前
二.前端web开发:零基础吃透 CSS 核心知识
前端·css
思码梁田2 天前
CSS display 属性:从元素类型转换到隐藏元素的实用指南
前端·css·display·inline·block·none·inline-block
weipt2 天前
springboot项目运行的几种方式
javascript·css·html
用户059540174462 天前
把AI对话记忆存储测试从手工改成Playwright+pytest,覆盖率从20%提到96%,回归时间缩短90%
前端·css
醉城夜风~2 天前
CSS盒模型(Box Model)
前端·css
呼噜想睡觉2 天前
Flex弹性布局
css·html·css3
用户059540174463 天前
「记仇」记忆存储测试踩坑实录:用 Pytest+Docker 把 BUG 扼杀在凌晨 3 点前
前端·css