如何从左到右以40度角旋转图像?

时间:2018-01-16 23:52:48

标签: javascript jquery

我正在尝试使用jQuery或js在上传后不断地从左到右旋转图像(没有按钮)。

1 个答案:

答案 0 :(得分:0)

试试这个希望它会有所帮助。

const img = document.getElementsByTagName("img")[0]
img.addEventListener("load", function(){
  img.classList.remove('rotateRight');
  img.classList.add('rotateLeft');
});
img{
heigth :200px;
width : 200px;
-webkit-transition: all 1s ease-in-out;
-moz-transition: all 1s ease-in-out;
-o-transition: all 1s ease-in-out;
transition: all 1s ;
}
.rotateRight{
transform: rotate(-40deg);
}
.rotateLeft{
transform: rotate(40deg);
}
<div>
<img class ="rotateRight" src='https://www.w3schools.com/w3css/img_fjords.jpg'/> 
</div>