all
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.
CSS all
简写属性 将除了 unicode-bidi
与 direction
之外的所有属性重设至其初始值,或继承值。
尝试一下
语法
/* Global values */
all: initial
all: inherit
all: unset
/* CSS Cascading and Inheritance Level 4 */
all: revert;
all
属性被作为 CSS 全局关键词的其中之一。不过需要注意的是,unicode-bidi
与 direction
这两个属性是不受 all
影响的
取值
形式定义
形式语法
示例
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;
}
结果
A. 没有 all
属性
<blockquote>
使用浏览器默认样式,以及另外的定义的背景色与文字颜色。它是一个 block 元素:它之后的文字位于它的下方。
B. all: initial
<blockquote>
没有使用浏览器默认样式:它现在是一个 inline 元素(初始值),其 background-color
为 transparent
(初始值),但其 font-size
仍为 small
(继承值),其 color
为 blue
(继承值)。
C. all:initial
<blockquote>
没有使用浏览器默认样式:它现在是一个 inline 元素(初始值),其 background-color
为 transparent
(初始值),其 font-size
为 normal
(初始值),其 color
为 black
(初始值)。
D. all:inherit
<blockquote>
没有使用浏览器默认样式:它现在是一个 block 元素(继承自其父元素 <body>
),其 background-color
为 transparent
(继承值),其 font-size
为 small
(继承值),其 color
为 blue
(继承值)。
规范
Specification |
---|
CSS Cascading and Inheritance Level 4 # all-shorthand |
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
all |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support