开发者社区> 问答> 正文

请问css3的transition属性可否被子元素继承?

如题,就是给父元素设置上transition,那么子元素会有transition么?

在w3c规范里是否有这个的规范?能否给个链接

展开
收起
杨冬芳 2016-06-02 11:09:02 2126 0
2 条回答
写回答
取消 提交回答
  • 热衷于研究前端新知识,学习新技术。精通HTML5+CSS3,Javascript,jQuery,Angular,Bootstrap。

    不会继承

    2019-07-17 19:24:21
    赞同 展开评论 打赏
  • IT从业

    文档地址: http://dev.w3.org/csswg/css-transitions/
    CRTL+F 查"inherited"结果都是NO.
    这些属性包括:

    transition-property
    transition-duration
    transition-timing-function
    transition-delay Property
    transition Shorthand

    关于继承性,文档中提到了一点

    EXAMPLE 4

    An example where maintaining the set of completed transitions is necessary would be a transition on an inherited property, where the parent specifies a transition of that property for a longer duration (say, transition: 4s text-indent) and a child element that inherits the parent’s value specifies a transition of the same property for a shorter duration (say, transition: 1s text-indent). Without the maintenance of this set of completed transitions, implementations could start additional transitions on the child after the initial 1 second transition on the child completes.

    这里提到了一个场景,如果parent指定的transition作用到的属性和child指定的transtions作用到的属性是同一个,而且parent的transtion过渡时间更长,那么就需要自己去维护transition的完成状态(完成后移除?我注)。
    例如:

    <div class="parent">
        <div class="child"></div>
    </div>
    .parent {
     transition: 4s text-indent;
    }
    .child{
     transition: 1s text-indent;
    }

    如有错误欢迎指正。

    2019-07-17 19:24:21
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
零基础CSS入门教程 立即下载
低代码开发师(初级)实战教程 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载