How to mix css3 transform properties without overriding (in realtime)?

前端 未结 6 1634
灰色年华
灰色年华 2020-12-11 00:26

Is there any way to combine (mix) css transform properties without overriding? For example there I want to rotate and scale. http://jsfiddle.net/hyzhak/bmyN3/

html<

6条回答
  •  感动是毒
    2020-12-11 00:52

    One thing you could do is get the computed transform style in JS and concatenate your secondary transform value:

    HTML

    CSS

    .rotate-scale {
       transform: rotate(90deg);
    }
    

    JS

    var el = document.querySelector('.rotate-scale'),
        // rotation will get the transform value declared in css
        rotation = window.getComputedStyle(el).getPropertyValue('transform');
    
    el.style.transform = rotation + 'scale(0.25, 0.25)';
    

提交回复
热议问题