0
点赞
收藏
分享

微信扫一扫

CSS 3.0特效时钟


在开发中,时钟的效果大多都是用JS来实现的,其实不借助JS,纯粹用CSS也是可以实现的,以下是我做的一个简单尝试的效果:

CSS 3.0特效时钟_CSS

以下是代码实现,欢迎大家复制粘贴和收藏。

<!doctype html>
<html lang="zh-cn">
<head>
<title>CSS 3.0特效时钟</title>
<meta charset="utf-8">
<style>
#clock {
width: 400px;
height: 400px;
border: 6px solid #369;
border-radius: 50%;
position: relative;
left:50%;
transform: translate(-50%);
}
#minute {
width: 10px;
height: 100px;
background-color: #963;
position: absolute;
top: 100px;
left: 195px;
/*指定旋转原点*/
transform-origin: center bottom;
/*以上由过渡效果改为动画效果*/
animation: scroll 3600s linear infinite;
}

#second {
width: 6px;
height: 150px;
background-color: #693;
position: absolute;
top: 50px;
left: 197px;
/*指定旋转原点*/
transform-origin: center bottom;
/*过渡属性+过渡时间+过渡时间曲线+过渡延迟时间,过渡属性2+过渡时间2*/
/*transition:transform 60s linear 2s;*/

/*以上由过渡效果改为动画效果*/
animation: scroll 60s linear infinite;
}

#second:hover {
/*过渡属性:旋转360度*/
transform: rotate(360deg);
}

/*声明动画*/
@keyframes scroll {
0% {
transform: rotate(0deg);
}

100% {
transform: rotate(360deg);
}
}
</style>
</head>

<body>
<div id="clock">
<div id="minute"></div>
<div id="second"></div>
</div>
</body>

</html>

举报

相关推荐

0 条评论