小结
CSS all简写属性重设除了unicode-bidi 和direction之外的所有属性至它们的初始值或继承值。
| 初始值 | There is no practical initial value for it. |
|---|---|
| 适用元素 | all elements |
| 是否是继承属性 | 否 |
| 适用媒体 | 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 |
语法
Formal syntax: initial | inherit | unset
all: initial all: inherit all: unset
值
initial- 该关键字代表改变该元素或其父元素的所有属性至初始值。
unicode-bidi和direction不受影响。 inherit- 该关键字代表改变该元素或其父元素的所有属性的值至他们的父元素属性的值。
unicode-bidi和direction不受影响。 unset- 该关键字代表如果该元素的属性的值是可继承的,则改变该元素或该元素的父元素的所有属性的值为他们父元素的属性值,反之则改变为初始值。
unicode-bidi和direction不受影响。
示例
HTML
<blockquote id="quote">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</blockquote> Phasellus eget velit sagittis.
CSS
html {
font-size: small;
background-color: #F0F0F0;
color: blue;
}
blockquote {
background-color: skyblue;
color: red;
}
Results in:
没有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 (继承值)。
规范
| 规范 | 状态 | 备注 |
|---|---|---|
| CSS Cascading and Inheritance Level 3 all |
Candidate Recommendation | 首次定义 |
浏览器兼容性
| Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|
| Basic support | 37 | 27 (27) | 11 | 24 | 未实现 |
| Feature | Android | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|
| Basic support | 未实现 | 27.0 (27) | 未实现 | 未实现 | 未实现 |