当我对一个元素使用 transform 进行 translate3d 和 rotate3d 时,该元素开始旋转。我想要旋转时的线性运动。
我在css中使用了webkit动画
img{height:50px;
width:50px;
animation:tt;
animation-duration:10s;
position:relative;
top:40vh;
left:40vw;}
@keyframes tt
{ 0%{
transform:rotate3d(0,0,0,0) translate3d(0,0,0);
}
50%{
transform:rotate3d(0,0,1,2000deg) translate3d(300px,0,0);
}
}
我希望它像汽车轮胎一样旋转时向前移动,而不是像 cometd 或激发的电子一样
最佳答案
您可以使用 left
和 right
CSS 属性,类似于 https://www.w3schools.com/css/css3_animations.asp 上的示例
我已经包含了下面的代码片段: https://codepen.io/mohamedhmansour/pen/bOONQr
img {
height: 50px;
width: 50px;
animation: tt;
animation-duration: 5s;
position: relative;
top: 0;
left: 0;
}
@keyframes tt {
0% {
transform: rotate(0deg);
left: 0px;
}
50% {
transform: rotate(-360deg);
left: 100%;
}
100% {
transform: rotate(0deg);
left: 0px;
}
}
<div class="wrapper">
<img src="http://blog.codepen.io/wp-content/uploads/2012/06/Button-Fill-Black-Small.png" />
</div>
关于html - 如何在使用CSS旋转时线性移动元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54168015/