所有 | all
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
不受影响。
正式语法
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 |