search

Home  >  Q&A  >  body text

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

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

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

阿神阿神2785 days ago627

reply all(3)I'll reply

  • 迷茫

    迷茫2017-04-17 11:13:52

    Document address: http://dev.w3.org/csswg/css-transitions/
    CRTL F checks "inherited" and the results are NO.
    These properties include:

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

    About inheritance, the documentation mentions something

    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.

    A scenario is mentioned here. If the attributes affected by the transition specified by the parent are the same as the attributes affected by the transitions specified by the child, and the parent's transition transition time is longer, then you need to maintain the completion status of the transition yourself. (Remove after completion? I note).
    For example:

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

    Please correct me if there are any errors.

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 11:13:52

    No. I tried it on Google, but it didn't work.

    reply
    0
  • 迷茫

    迷茫2017-04-17 11:13:52

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

    reply
    0
  • Cancelreply