:root 选择器
:root 选择器
定义和用法:
:root选择器用匹配文档的根元素。
在HTML中根元素始终是HTML元素
浏览器支持:
选择器 | ![]() | ![]() | ![]() | ![]() | ![]() |
:root | 9.0 | 3.5 | 9.6 | 4.0 | 3.2 |
CSS语法:
:root{ css语法; }
实例
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> <style> :root { background:pink; } </style> </head> <body> <p>设置HTML文档颜色</p> </body> </html>
运行实例 »
点击 "运行实例" 按钮查看在线实例
效果图:
任务
- ?不会了怎么办