CSS中可继承的属性

html-css018

CSS中可继承的属性,第1张

所有元素可继承 :visibility(可见性)和 cursor (光标属性)

内联元素可继承 :font、font-size、font-family、font-style、font-variant、font-weight、text-decoration、text-align、letter-spacing、word-spacing、white-space、line-height、color、

块级元素可以继承的属性 :text-indent、text-align、

列表元素可继承 :list-style、list-style-type、list-style-position、list-style-image、

可以使用 CSS 的 all 属性。但是目前IE和Edge浏览器还没有任何版本兼容这个属性。所以实际开发中,如果需要兼容IE或者Edge的话,不能使用。同时安卓4.4以及以下,Safari9 的部分版本也不支持。

还是简单的说下用法:

all 属性可以重置选中元素的属性(除了direction和unicode-bidi两个属性)

all 属性在Cascading and Inheritance Level 3 规范中有三个可选的值

initial : 重置所有CSS属性为初始值

inherit : 元素继承所有服元素的CSS属性,即使有些属性原本不是可继承的

unset : 元素继承服元素所有可继承的属性

同时在 Cascading and Inheritance Level 4 规范草案中增加了 revert 值。由于还仅仅是草案,所以这里不细说,详情可以异步下面的链接。

W3C 相关标准内容:

https://www.w3.org/TR/css-cascade-3/#defaulting

https://drafts.csswg.org/css-cascade/#all-shorthand