漂浮的白云主要通过远景白云和近景白云来实现立体漂浮效果。远景和近景分别使用两张背景图片,通过改变其背景定位来实现白云移动效果,通过设置不同的动画持续时间来实现交错漂浮的效果
.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;
}
💡 关键要点
漂浮的白云主要通过远景白云和近景白云来实现立体漂浮效果。远景和近景分别使用两张背景图片,通过改变其背景定位来实现白云移动效果,