所有 | all

all

CSSall简写属性重设除了unicode-bididirection之外的所有属性至它们的初始值或继承值。

/* 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 typeas 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 (继承值)。

规范

SpecificationStatusComment
CSS Cascading and Inheritance Level 4The definition of 'all' in that specification.Working DraftAdded the revert value.
CSS Cascading and Inheritance Level 3The definition of 'all' in that specification.Candidate RecommendationInitial definition.

浏览器兼容性

FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support3727 (27)No support24No support
revertNo supportNo supportNo supportNo support9.1

FeatureAndroidFirefox Mobile (Gecko)IE PhoneOpera MobileSafari Mobile
Basic supportNo support27.0 (27)No supportNo supportNo support
revertNo supportNo supportNo supportNo support9.3