未设置 | unset (Cascading & Inheritance) - CSS 中文开发手册 - Break易站

  •   CSS 中文开发手册

    未设置 | unset (Cascading & Inheritance) - CSS 中文开发手册

    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>

    结果:

    规范

    Specification

    Status

    Comment

    CSS Cascading and Inheritance Level 4The definition of 'unset' in that specification.

    Working Draft

    No changes from Level 3.

    CSS Cascading and Inheritance Level 3The definition of 'unset' in that specification.

    Candidate Recommendation

    Initial definition.

    浏览器兼容性

    Feature

    Chrome

    Firefox (Gecko)

    Internet Explorer

    Opera

    Safari

    Basic support

    41

    27 (27)

    Edge build 10565+

    28

    9.1

    Feature

    Android

    Firefox Mobile (Gecko)

    IE Phone

    Opera Mobile

    Safari Mobile

    Basic support

    No support

    27.0 (27)

    No support

    No support

    9.3

  •   CSS 中文开发手册
    转载请保留页面地址:https://www.breakyizhan.com/css/32059.html

    posted on 2020-07-01 21:55  MrAit  阅读(192)  评论(0编辑  收藏  举报

    导航