How can I apply multiple transform declarations to one element?

前端 未结 4 497
夕颜
夕颜 2020-12-03 09:49

I have an element with two classes, one called \"rotate\" that will rotate the element 360 degrees and another called \"doublesize\" that will scale the element 2x its nor

4条回答
  •  情深已故
    2020-12-03 10:17

    You can't do this using just CSS, but if you don't mind using some jQuery, you can attach this effect using some jQuery:

    var $elem = $('.cssDropPinImage');
    $({ deg: 0 }).animate({ deg: 359 }, {
        duration: 600,
        step: function (now) {
            var scale = (2 * now / 359);
            $elem.css({
                transform: 'rotate(' + now + 'deg) scale(' + scale + ')'
            });
        }
    });
    

    Hope this helps other readers, facing the same problem.

提交回复
热议问题