关于云朵的进入和消失
我写的代码实现不了案例中的效果,请老师告诉我怎么改进。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
body{
margin: 0; padding: 0;
overflow: hidden;
}
.sky{
width: 100%;
height: 60vh;
/* background: rgb(196, 228, 253) */
background: linear-gradient(0deg, #fff , rgb(196, 228, 253))
}
.grass{
width: 100%;
height: 40vh;
/* background: rgb(148, 190, 89) */
background: linear-gradient(0deg, rgb(148, 190, 89), #fff)
}
.rabbit{
width: 300px;
height: 300px;
position: absolute;
bottom: 50px;
right: 150px;
background: url(./rabbit.png) no-repeat center;
background-size: 100%
}
.cloud{
width: 100px;
height: 100px;
background: #fff;
position: relative;
left: 100px;
border-radius: 50%;
}
.cloud::before{
content: '';
position: absolute;
left: -80px;
bottom: 5px;
width: 190px;
height: 50px;
background: #fff;
border-radius: 25px 25px 30px 30px/ 25px 25px 25px 25px;
}
.cloud::after{
content: '';
position: absolute;
left: -49px;
bottom: -12px;
width: 70px;
height: 95px;
background: #fff;
border-radius: 35px / 35px 35px 35px 35px;
transform: rotate(-45deg)
}
.cloud.one{
position: absolute;
top: 0px;
left: 80px;
transform: scale(.7, .7);
z-index: 7;
opacity: .7;
}
.cloud.two{
position: absolute;
top: 100px;
left: 300px;
z-index: 9;
opacity: .9;
animation: cloud_two 5s linear infinite;
/* transform: translateX(0px) */
}
.cloud.three{
position: absolute;
top: 200px;
left: 250px;
z-index: 8;
opacity: .8;
transform: scale(.8, .8)
}
.cloud.four{
position: absolute;
top: 0px;
left: 650px;
z-index: 8;
opacity: .8;
transform: scale(.8, .8)
}
.cloud.five{
position: absolute;
top: 200px;
left: 800px;
z-index: 7;
opacity: .7;
transform: scale(.7, .7)
}
@keyframes cloud_two {
from{
left: 300px;
/* transform: translateX(0px) */
}
50%{
left: -300px
/* transform: translateX(2000px) */
}
to{
left: 2000px
/* transform: translateX(-200px) */
}
}
</style>
</head>
<body>
<div class="sky">
<div class="cloud one"></div>
<div class="cloud two"></div>
<div class="cloud three"></div>
<div class="cloud four"></div>
<div class="cloud five"></div>
</div>
<div class="grass"></div>
<div class="rabbit"></div>
</body>
</html>3
收起
正在回答 回答被采纳积分+1
1回答


恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星