请问css3的transition属性可否被子元素继承?
阿神
阿神 2017-04-17 11:11:52
0
3
669

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

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

阿神
阿神

闭关修行中......

全部回覆(3)
迷茫

文檔地址: 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的完成狀態(完成後移除?我注)。
例如:

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

如有錯誤歡迎指正。

Ty80

不能。我在穀歌下試了,不能。

迷茫

不能 https://developer.mozilla.org/en-US/docs/Web/CSS/transition

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板