之前练习的一个网页,只利用css完成,算是一个小demo吧
想要的效果:
- 云层无限滚动
- 背景天空会由白变黑再变白
- 云层滚动有视差(速度不同)
效果图:
代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>5_动画模块_云层效果</title>
<style>
* {
margin: 0;
padding: 0;
}
ul {
height: 400px;
background-color: skyblue;
margin-top: 100px;
animation: change 5s linear 0s infinite alternate;
position: relative;
overflow: hidden;
}
ul li {
width: 400%;
height: 100%;
position: absolute;
left: 0;
top: 0;
list-style: none;
}
ul li:nth-child(1) {
background-image: url("pic/yun1.png");
animation: one 30s linear 0s infinite alternate;
}
@keyframes one {
from{margin-left: 0px;
}
to{margin-left: -100%;
}
}
ul li:nth-child(2) {
background-image: url("pic/yun2.png");
animation: two 30s linear 0s infinite alternate;
}
@keyframes two {
from {margin-left: 0px;
}
to {margin-left: -200%;
}
}
ul li:nth-child(3) {
background-image: url("pic/yun3.png");
animation: three 30s linear 0s infinite alternate;
}
@keyframes three {
from {margin-left: 0px;
}
to {margin-left: -300%;
}
}
@keyframes change {
from {
background-color: skyblue;
}
to {
background-color: black;
}
}
</style>
</head>
<body>
<ul>
<li></li>
<li></li>
<li></li>
</ul>
</body>
</html>
yun1.png,到yun3.png:
ps扣的,不咋滴