未设置 | unset

unset

unsetCSS关键词当它从其父继承了继承值,而其初始值没有,则unset重置属性。换句话说,它inherit在第一种情况下就像initial关键字,而在第二种情况下就像关键字一样。它可以应用于任何CSS属性,包括CSS简写all

示例

颜色

.foo { color: blue; } .bar { color: green; } p { color: red; } .bar p { color: unset; }

<p>This text is red.</p> <div class="foo"> <p>This text is also red.</p> </div> <div class="bar"> <p>This text is green (default inherited value).</p> </div>

结果:

边界

div { border: 1px solid green; } p { border: 1px solid red; } .bar p { border-color: unset; }

<p>This text has a red border.</p> <div> <p>This text has a red border.</p> </div> <div class="bar"> <p>This text has has a black border (initial default, not inherited).</p> </div>

结果:

规范

SpecificationStatusComment
CSS Cascading and Inheritance Level 4The definition of 'unset' in that specification.Working DraftNo changes from Level 3.
CSS Cascading and Inheritance Level 3The definition of 'unset' in that specification.Candidate RecommendationInitial definition.

浏览器兼容性

FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support4127 (27)Edge build 10565+289.1

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