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 小时前
CSS高效开发三大方向
前端·css
昔人'12 小时前
css`font-variant-numeric: tabular-nums` 用来控制数字的样式。
前端·css
不叫猫先生19 小时前
中秋连连看小游戏开发完整教程
javascript·css·小游戏·连连看
西洼工作室2 天前
SSE与轮询技术实时对比演示
前端·javascript·css
Dontla2 天前
Tailwind CSS介绍(现代CSS框架,与传统CSS框架Bootstrap对比)Tailwind介绍
前端·css·bootstrap
向上的车轮2 天前
CSS 预处理器:Sass的基本用法、核心特性
css·sass
清灵xmf3 天前
CSS field-sizing 让表单「活」起来
前端·css·field-sizing
面向星辰4 天前
css选择器(继承补充)
前端·css
敲代码的嘎仔4 天前
JavaWeb零基础学习Day1——HTML&CSS
java·开发语言·前端·css·学习·html·学习方法
Tachyon.xue4 天前
Vue 3 项目集成 Element Plus + Tailwind CSS 详细教程
前端·css·vue.js