css - 秒针旋转问题
本文介绍了css - 秒针旋转问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
.seconds {
position: absolute;
width: 8%;
height: auto;
bottom: 11.5%;
left: 45.5%;
-webkit-transform-origin: center 72.4%;
-webkit-animation: second 60s infinite linear;
}
@-webkit-keyframes second {
to {
-webkit-transform: rotate(355deg);
}
}
.second是一个秒针的图片,这里的355deg不理解,我改成-5deg怎么就不动了?而且这个秒针是顺时针转的。
解决方案
rotate(<angle>)
<angle>为正数时顺时针
<angle>为负数时逆时针
设为-5deg的时候不是没动,你仔细看有动,只是你的整个动画过程设为60秒了。。也就是说5deg逆时针需要走60秒
<body>
<div class="clock">
<div class="seconds"></div>
</div>
<style type="text/css">
* {
margin: 0;
padding: 0;
}
.clock {
position: relative;
width: 301px;
height: 301px;
border: 8px solid #f55;
border-radius: 100%;
}
.seconds {
position: absolute;
width: 2px;
height: 140px;
background-color: #f55;
top: 150px;
left: 150px;
transform-origin: 50% 0%;
animation: second 60s infinite linear;
}
@-webkit-keyframes second {
to {
-webkit-transform: rotate(360deg);//每60秒顺时针走360度,就是一整圈
-webkit-transform: rotate(-5deg);//每60秒只逆时针走5度,走完一圈要4320秒
}
}
</style>
</body>
设为-5deg时,可以看到在一直动,1小时12分就逆时针转一圈。。
这篇关于css - 秒针旋转问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文