CSS参考手册
选择 | Selectors
:root
该:root
CSS伪类与表示该文档的文档树的根元素相匹配。在HTML中,:root
表示<html>
元素,并且与选择器html
相同,只是其特异性更高。
/* Selects the root element of the document */
/* <html> in the case of HTML */
:root {
background: yellow;
}
语法
:root
实例
:root
可以用于声明全局CSS变量:
:root {
--main-color: hotpink;
--pane-padding: 5px 42px;
}
规范
Specification |
Status |
Comment |
---|---|---|
Selectors Level 4The definition of ':root' in that specification. |
Working Draft |
No change |
Selectors Level 3The definition of ':root' in that specification. |
Recommendation |
Initial definition |
浏览器兼容性
Feature |
Chrome |
Edge |
Firefox (Gecko) |
Internet Explorer |
Opera |
Safari |
---|---|---|---|---|---|---|
Basic support |
1 |
(Yes) |
1.0 (1.7 or earlier) |
9 |
9.5 |
1.0 |
Feature |
Android |
Edge |
Firefox Mobile (Gecko) |
IE Mobile |
Opera Mobile |
Safari Mobile |
---|---|---|---|---|---|---|
Basic support |
? |
(Yes) |
? |
? |
? |
? |
选择 | Selectors相关
层叠样式表( Cascading Style Sheets )是一种用来表现 HTML 或 XML 等文件样式的计算机语言。CSS 不仅可以静态地修饰网页,还可以配合各种脚本语言动态地对网页各元素进行格式化。