:root
:root CSS 偽類匹配表示文件樹的根元素。在 HTML 中,:root 表示 <html> 元素,與選擇器 html 相同,不同之處在於它的 特異性 更高。
css
/* Selects the root element of the document:
<html> in the case of HTML */
:root {
background: yellow;
}
語法
css
:root {
/* ... */
}
示例
宣告全域性 CSS 變數
:root 可用於宣告全域性 CSS 變數
css
:root {
--main-color: hotpink;
--pane-padding: 5px 42px;
}
規範
| 規範 |
|---|
| 選擇器 Level 4 # root-pseudo |
瀏覽器相容性
載入中…