利用css3实现了日食效果。
代码实例如下:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="http://www.softwhy.com/" />
<title>web前端开发学习q群:731771211 技术分享,欢迎基础小伙伴</title>
<style>
* {
margin: 0;
padding: 0;
}
body {
background: #222;
}
.sky {
position: relative;
padding-top: 15px;
width: 800px;
height: 600px;
margin: 150px auto;
}
.moon {
margin: 0 auto;
width: 200px;
height: 200px;
background-color: #f3f3f3;
border-radius: 50%;
box-shadow:6px 6px 10px #666, 6px -6px 10px #666, -6px 6px 10px #666, -6px -6px 10px #666;
}
.dog {
position: absolute;
top: 15px;
left: 90px;
width: 200px;
height: 200px;
background-color: #222;
border-radius: 50%;
animation: dogEatMoon 8s ease-out infinite;
}
@keyframes dogEatMoon {
0% {
left: 90px;
}
35% {
left: 300px;
}
55% {
left: 300px;
}
100% {
left: 520px;
}
}
</style>
</head>
<body>
<div class="sky">
<div class="moon"></div>
<div class="dog"></div>
</div>
</body>
</html>
网友评论