呼吸灯效果(极简css实现)
效果展示

在这里插入图片描述
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: #263238;
}
section {
width: 650px;
height: 300px;
padding: 10px;
position: relative;
display: flex;
align-items: center;
justify-content: center;
border: 2px solid red;
}
span {
width : 96px;
height: 96px;
background: white;
border-radius: 50%;
animation: animloader 1s ease-in infinite;
}
@keyframes animloader {
0% { transform: scale(0); opacity: 1;}
100% { transform: scale(1); opacity: 0;}
}
原理详解
步骤1
使用span标签,设置
- 宽度、高度均为96px
- 背景色:白色
width : 96px;
height: 96px;
background: white;
效果图如下

在这里插入图片描述
步骤2
span圆角化
border-radius: 50%;
效果图如下

步骤3
为span设置动画
- 初始状态:大小为0(相对于原大小),颜色为(白,透明级别1)
- 终止状态:大小为1(相对于原大小),颜色为(白,透明级别0)
animation: animloader 1s ease-in infinite;
@keyframes animloader {
0% { transform: scale(0); opacity: 1;}
100% { transform: scale(1); opacity: 0;}
}
效果图如下

在这里插入图片描述
相关推荐
-
mysql索引类型 normal, unique, full text
mysql索引类型 normal, unique, full text2025-02-24 10:05:05 -
uwsgi+django+nginx 搭建部分总结2025-02-24 10:03:33
-
使用Docker配置Nginx环境部署Nextcloud2025-02-24 10:02:03
-
Nginx安装和怎么使用2025-02-24 10:00:45
-
PHP8种变量类型的详细讲解2025-02-22 00:32:24