【动画消消乐】纯CSS绘制一朵白云 071
海轰Pro
共 4564字,需浏览 10分钟
·
2021-06-07 00:17
效果展示
![](https://filescdn.proginn.com/601d6a21dc32bdf72a158aba1ee1c24f/11f208aecf4f9faf36c3eff296b1a7c0.webp)
Demo代码
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<title>Document</title>
</head>
<body>
<section>
<span></span>
</section>
</body>
</html>
CSS
html, body {
margin: 0;
height: 100%;
}
body {
display: flex;
justify-content: center;
align-items: center;
background: #93b5cf;
}
section {
width: 650px;
height: 300px;
padding: 10px;
position: relative;
display: flex;
align-items: center;
justify-content: center;
border: 2px solid orange;
}
/*白云*/
span {
background: white;
border-radius: 50%;
box-shadow: white 65px -15px 0 -4px, /*阴影1*/
white 25px -25px, /*阴影2*/
white 30px 10px, /*阴影3*/
white 60px 15px 0 -10px, /*阴影4*/
white 85px 5px 0 -5px; /*阴影5*/
height: 50px;
width: 50px;
margin-left: -60px;
position: relative;
}
原理详解
步骤1
使用span标签,设置为
相对定位 宽度、高度均为50px 背景色:白色
span {
background: white;
height: 50px;
width: 50px;
position: relative;
}
效果图如下
![](https://filescdn.proginn.com/cdf4df3d2368ea7ebc87d270ed03b019/33aaef9b32f71e523133842d80a28078.webp)
步骤2
利用box-shadow属性,为span添加5个阴影
box-shadow: red 65px -15px 0 -4px, /*阴影1*/
orange 25px -25px, /*阴影2*/
yellow 30px 10px, /*阴影3*/
green 60px 15px 0 -10px, /*阴影4*/
blue 85px 5px 0 -5px; /*阴影5*/
效果图如下
![](https://filescdn.proginn.com/91dbf661335e391322e78b86be0298a3/ac80c37cadcd9db8ad17eebda5edafe6.webp)
步骤3
span圆角化
span {
border-radius: 50%;
}
效果图如下
![](https://filescdn.proginn.com/b700d578b42fd13c0fb7e34f400c9b1b/6f1317257a727b733037dd00fae2cc52.webp)
步骤4
将5个阴影的颜色都修改为白色
box-shadow: white 65px -15px 0 -4px, /*阴影1*/
white 25px -25px, /*阴影2*/
white 30px 10px, /*阴影3*/
white 60px 15px 0 -10px, /*阴影4*/
white 85px 5px 0 -5px; /*阴影5*/
效果图如下
![](https://filescdn.proginn.com/d189e8ab731c7f5d576e613aa05b71e1/c2a2ed1a3d7f5428274c4bf9eefc5a3d.webp)
步骤5
将span左移60px
span {
margin-left: -60px;
}
得到一朵小白云
![](https://filescdn.proginn.com/a87235f9f03dfffcfb4adc3cf28062f2/c6ed72d3b9c783c83a80abd7782f98ae.webp)
结语
希望对您有所帮助
如有错误欢迎小伙伴指正~
我是 海轰ଘ(੭ˊᵕˋ)੭
如果您觉得写得可以的话
请点个赞吧
谢谢支持❤️
![](https://filescdn.proginn.com/fe49d07ce0e6be96b951a3a713edd0dd/2f1c2e35867f2cb77c2eaebd40fc5cce.webp)
评论