Multiple, simultaneous CSS3 transform transitions at varied speeds

后端 未结 4 589
栀梦
栀梦 2021-01-12 03:10

Question:

Is it even possible to do two different transforms on an element and have them transition at different speeds?

Example without transforms (Fiddl

4条回答
  •  醉梦人生
    2021-01-12 03:28

    Don't think you can do it the way you are attempting. Possible solutions would be a wrapper object

    eg

    Multiple transitions

    sample fiddle here

    sample code (HTML)

    and CSS

    .wrap {
        width: 100px;
        height: 100px;
        transition: transform 1s linear;
    }
    .inner {
        width: 100%;
        height: 100%;
        background: red;
        transition: transform 2s linear;
    }
    .wrap:hover {
        transform: scale(1.5);
    }
    .wrap:hover .inner {
        transform: rotate(45deg);
    }
    

    or use animations and keyframes as mentioned in answer by @slynagh

    Just out of note, the transform property doesn't seem to work when used in transition on chrome (i.m on V33), but it works fine on IE11, thats all I have tested this on

提交回复
热议问题