定义和用法
all
属性将除 unicode-bidi 和 direction 之外的所有属性重置为其初始值或继承的值。
实例
将应用于元素或元素父元素的所有属性更改为其初始值:
<!DOCTYPE html>
<html>
<head>
<style>
html {font-size: small;color: blue;
}#ex1 {background-color: yellow;color: red;
}#ex2 {background-color: yellow;color: red;all: inherit;
}#ex3 {background-color: yellow;color: red;all: initial;
}#ex4 {background-color: yellow;color: red;all: unset;
}
</style>
</head>
<body><p>未设置 all 属性:</p>
<div id="ex1">Shanghai is one of the four direct-administered municipalities of the People's Republic of China. Welcome to Shanghai!</div><p>all: inherit:</p>
<div id="ex2">Shanghai is one of the four direct-administered municipalities of the People's Republic of China. Welcome to Shanghai!</div><p>all: initial:</p>
<div id="ex3">Shanghai is one of the four direct-administered municipalities of the People's Republic of China. Welcome to Shanghai!</div><p>all: unset:</p>
<div id="ex4">Shanghai is one of the four direct-administered municipalities of the People's Republic of China. Welcome to Shanghai!</div></body>
</html>
CSS 语法
all: initial|inherit|unset;
属性值
值 | 描述 |
---|---|
initial | 将此属性设置为其默认值。 |
inherit | 从其父元素继承此属性。 |
unset | 如果可继承,则将应用于元素或元素父元素的所有属性更改为其父值,否则将其更改为初始值。 |
技术细节
默认值: | none |
---|---|
继承: | 否 |
动画制作: | 不支持。 |
版本: | CSS3 |
JavaScript 语法: | object.style.all="initial" |
浏览器支持
表格中的数字注明了完全支持该属性的首个浏览器版本。
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | IE / Edge | Firefox | Safari | Opera |
37.0 | 79.0 | 27.0 | 9.1 | 24.0 |