CSS参考手册
级联和继承 | Cascading & Inheritance
所有 | all
CSSall
简写属性重设除了unicode-bidi
和direction
之外的所有属性至它们的初始值或继承值。
/* Global values */
all: initial;
all: inherit;
all: unset;
/* CSS Cascading and Inheritance Level 4 */
all: revert;
初始值 |
There is no practical initial value for it. |
---|---|
适用元素 |
all elements |
是否是继承属性 |
no |
适用媒体 |
There is no practical media for it. |
计算值 |
as the specified value applies to each property this is a shorthand for. |
Animation type |
as each of the properties of the shorthand (all properties but unicode-bidi and direction) |
正规顺序 |
the unique non-ambiguous order defined by the formal grammar |
语法
值
initial
该关键字代表改变该元素或其父元素的所有属性至初始值。 unicode-bidi
和 direction
不受影响。
inherit
该关键字代表改变该元素或其父元素的所有属性的值至他们的父元素属性的值。 unicode-bidi
和 direction
不受影响。
unset
该关键字代表如果该元素的属性的值是可继承的,则改变该元素或该元素的父元素的所有属性的值为他们父元素的属性值,反之则改变为初始值。unicode-bidi
和 direction
不受影响。
正式语法
initial | inherit | unset
示例
HTML
<blockquote id="quote">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</blockquote> Phasellus eget velit sagittis.
CSS
body {
font-size: small;
background-color: #F0F0F0;
color: blue;
}
blockquote {
background-color: skyblue;
color: red;
}
结果如下:
没有all
属性
<blockquote>
使用浏览器默认样式和定义的背景色和文字颜色。它表现为block元素:它之后的文字位于它的下方。
all:unset
<blockquote>
没有使用浏览器默认样式:它现在是个inline元素(初始值),它的background-color
是 transparent
(初始值),但它的font-size
仍是small
(继承值) ,它的color
是blue
(继承值)。
all:initial
<blockquote>
没有使用浏览器默认样式:它现在是个inline元素(初始值),它的background-color
是 transparent
(初始值),它的font-size
是normal
(初始值),它的color
是black
(初始值)。
all:inherit
<blockquote>
没有使用浏览器默认样式:它现在是个block元素(继承值),它的background-color
是 transparent
(继承值),它的font-size
是small
(继承值) ,它的 color
是blue
(继承值)。
规范
Specification |
Status |
Comment |
---|---|---|
CSS Cascading and Inheritance Level 4The definition of 'all' in that specification. |
Working Draft |
Added the revert value. |
CSS Cascading and Inheritance Level 3The definition of 'all' in that specification. |
Candidate Recommendation |
Initial definition. |
浏览器兼容性
Feature |
Chrome |
Firefox (Gecko) |
Internet Explorer |
Opera |
Safari |
---|---|---|---|---|---|
Basic support |
37 |
27 (27) |
No support |
24 |
No support |
revert |
No support |
No support |
No support |
No support |
9.1 |
Feature |
Android |
Firefox Mobile (Gecko) |
IE Phone |
Opera Mobile |
Safari Mobile |
---|---|---|---|---|---|
Basic support |
No support |
27.0 (27) |
No support |
No support |
No support |
revert |
No support |
No support |
No support |
No support |
9.3 |
级联和继承 | Cascading & Inheritance相关
层叠样式表( Cascading Style Sheets )是一种用来表现 HTML 或 XML 等文件样式的计算机语言。CSS 不仅可以静态地修饰网页,还可以配合各种脚本语言动态地对网页各元素进行格式化。