码迷,mamicode.com
首页 > Web开发 > 详细

inherit (Values & Units) – CSS 中文开发手册 - Break易站

时间:2020-07-13 21:27:05      阅读:91      评论:0      收藏:0      [点我收藏+]

标签:col   hat   make   hang   替代   oid   4th   ott   cti   

[
  • ??CSS 中文开发手册

    inherit (Values & Units) - CSS 中文开发手册

    inheritCSS关键字使得元素的指定属性值取其父元素的该属性的计算值。它可以应用于任何CSS属性,包括CSS简写属性all。

    对于继承的属性,这强化了默认行为,只需要覆盖另一个规则。对于非继承属性,这种指定行为通常就毫无意义,你可以考虑使用initial替代,或者在all属性中设置unset。

    即使父元素不是包含块,继承始终是从文档树中的父元素开始的。

    实例

    /* Make second-level headers green */
    h2 { color: green; }
    
    /* ...but leave those in the sidebar alone so they use their parent‘s color */
    #sidebar h2 { color: inherit; }

    在这个例子中边栏内的元素h2可能是不同的颜色。例如,如果其中之一是由规则匹配的div的孩子

    div#current { color: blue; }

    这将是蓝色的。

    规范

    Specification

    Status

    Comment

    CSS Cascading and Inheritance Level 4The definition of ‘inherit‘ in that specification.

    Working Draft

    No changes from Level 3.

    CSS Values and Units Module Level 3The definition of ‘inherit‘ in that specification.

    Candidate Recommendation

    No significant change from CSS Level 2 (Revision 1).

    CSS Level 2 (Revision 1)The definition of ‘inherit‘ in that specification.

    Recommendation

    Initial definition.

    浏览器兼容性

    Feature

    Chrome

    Firefox (Gecko)

    Internet Explorer

    Opera

    Safari (WebKit)

    Basic support

    1.0

    1.0 (1.7 or earlier)

    8.0

    4.0

    1.0 (85)

    Feature

    Android

    Firefox Mobile (Gecko)

    IE Phone

    Opera Mobile

    Safari Mobile

    Basic support

    1.0

    1.0 (1.0)

    ?

    ?

    (Yes)

    另见

    Inheritance继承

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

    inherit (Values & Units) – CSS 中文开发手册 - Break易站

    标签:col   hat   make   hang   替代   oid   4th   ott   cti   

    原文地址:https://www.cnblogs.com/breakyizhan/p/13295712.html

    (0)
    (0)
       
    举报
    评论 一句话评论(0
    登录后才能评论!
    © 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
    迷上了代码!