• 首页
  • css3教程
  • html5教程
  • jQuery手册
  • php7教程
  • MySQL手册
  • apache手册
  • unset

    版本:CSS3

    unsetCSS关键字。如果从其父级继承,则将该属性重新设置为继承的值,如果没有继承父级样式,则将该属性重新设置为初始值。换句话说,在第一种情况下(继承属性)它的行为类似于inherit,在第二种情况下(非继承属性)类似于initial。它可以应用于任何CSS属性,包括CSS简写属性all

    示例

    div{border:unset;}
    div{border:initial;}
    

    浏览器支持

    IE浏览器火狐浏览器opera浏览器chrome浏览器safari浏览器
    IE浏览器不支持unset,其余浏览器都支持unset

    语法

    property:unset;

    例子

    //CSS
    div {border: 1px solid green;}
    p {border: 1px solid red;}
    .bar p {border-color: unset;}
    
    //html
    
    <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>
    
    //html
    <p>this text is red.</p>
    <div class="foo">
      <p>this text is also red.</p>
    </div>
    <div class="bar">
      <p>this text is red (<span>default inherited value</span>).</p>
    </div>
    
    //CSS
    .foo {color: green;}
    .bar {color: blue;}
    
    p {
      color: red;
    }
    .bar p {
      color: unset;
    }
    

    This text is red.

    This text is also red.

    This text is red(default inherited value).

    上篇:initial

    下篇:@keyframes