animation(一):漂浮的白云

来源:互联网 发布:特朗普执政知乎 编辑:程序博客网 时间:2024/04/30 00:40

 漂浮的白云主要通过远景白云和近景白云来实现立体漂浮效果。远景和近景分别使用两张背景图片,通过改变其背景定位来实现白云移动效果,通过设置不同的动画持续时间来实现交错漂浮的效果


<!DOCTYPE html>

<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
.box{
position: relative;
height: 300px;
width: 500px;
}
.in1,.in2{
position: absolute;
height: 100%;
width: 100%;
background-size:cover;
-webkit-animation: move 100s infinite linear alternate;
animation: move 100s infinite linear alternate;
}
@-webkit-keyframes move{
100%{background-position: 500% 0;}
}
@keyframes move{
100%{background-position: 500% 0;}
}
.in1{
background-image: url('http://sandbox.runjs.cn/uploads/rs/26/ddzmgynp/cloud.png');

}
.in2{
background-image: url('http://sandbox.runjs.cn/uploads/rs/26/ddzmgynp/cloud1.png');
-webkit-animation-duration: 10s;
animation-duration: 10s;
}
</style>
</head>
<body>
<div class="box">
<div class="in1"></div>
<div class="in2"></div>
</div>
</body>
</html>
原创粉丝点击