CSS

[CSS] 根元素

2016-03-07  本文已影响141人  何幻

CSS 中的根元素是指 :root选择器匹配到的元素,
也就是文档树中最顶层结构的元素。

在不同的场景下具体的根元素不同。
在 HTML 中是<html>元素,但在其他情况下,就不是<html>元素。

(1)HTML

data:text/html, <div><style>:root { background: green; } html { background: red !important; }</style></div>

(2)XML

data:application/xhtml+xml,<div xmlns="http://www.w3.org/1999/xhtml"><style>:root { background: green; } html { background: red !important; }</style></div>

(3)SVG

data:image/svg+xml;utf8,<svg class="shadow" xmlns="http://www.w3.org/2000/svg" version="1.1"><polygon points="200,0 200,200 0,200"/><style>:root{background-color: green;}</style></svg>
上一篇 下一篇

猜你喜欢

热点阅读