So I have an element. And I want to rotate it, using JS.
It works, but it rotates around other points.
I need to rotate it around its own center. How do I do this?
$(window).on('scroll', function() {
var a = $(window).scrollTop();
$('.section-4 .photo .after').css('transform', 'rotate('+ (a / 10) +'deg)');
});
<div class = "rotateDiv"></div>
<img src = "http://static-note-i-1.heartynote.com/img/icons/head_logo.png">
<style>
img{
transform: rotate(160deg);
}
使用 CSS3 特性:
transform-origin: center
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.