新增第93个小实例:四色小球的loading动画

This commit is contained in:
DESKTOP-BM6RJU5\wyanh 2022-01-08 17:58:09 +08:00
parent 370172c5a4
commit 3d2691de3d
3 changed files with 85 additions and 1 deletions

View File

@ -96,4 +96,5 @@
89. HTML5+CSS3小实例自带射灯的浮雕按钮
90. HTML5+CSS3小实例超时空背景的登录界面
91. HTML5+CSS3小实例旋转的炫光心形loading动画
92. HTML5+CSS3小实例全屏搜索栏
92. HTML5+CSS3小实例全屏搜索栏
93. HTML5+CSS3小实例四色小球的loading动画

61
css/93.css Normal file
View File

@ -0,0 +1,61 @@
*{
/* 初始化 */
margin: 0;
padding: 0;
}
body{
/* 100%窗口高度 */
height: 100vh;
/* 弹性布局 水平+垂直居中 */
display: flex;
justify-content: center;
align-items: center;
background-color: #222;
}
.loader{
/* 相对定位 */
position: relative;
width: 250px;
height: 250px;
/* 默认旋转45度 */
transform: rotate(45deg);
/* 执行动画:动画名 时长 线性的 无限次播放 */
animation: roll 2.5s linear infinite;
}
.loader span{
position: absolute;
width: 100%;
height: 100%;
/* 通过var函数获取自定义属性--i计算每一个span元素的旋转角度 */
transform: rotate(calc(90deg * var(--i)));
}
.loader span::before{
content: "";
width: 70px;
height: 70px;
/* 调用自定义属性--c设置背景色 */
background-color: var(--c);
border-radius: 50%;
position: absolute;
/* 默认都居中 */
left: 50%;
top: 50%;
transform: translate(-50%,-50%);
/* 执行动画:动画名 时长 贝塞尔曲线 无限次播放 */
animation: move 2.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) infinite;
}
/* 定义动画 */
@keyframes move {
50%{
left: 0;
box-shadow: 0 0 5px var(--c),
0 0 10px var(--c),
0 0 20px var(--c);
}
}
@keyframes roll {
to{
transform: rotate(360deg);
}
}

22
html/93.html Normal file
View File

@ -0,0 +1,22 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
<title>四色小球的loading动画</title>
<link rel="stylesheet" href="../css/93.css">
</head>
<body>
<div class="loader">
<!-- --i、--c为自定义属性CSS中可通过var函数对其调用 -->
<span style="--i:1;--c:#2ecc71;"></span>
<span style="--i:2;--c:#3498db;"></span>
<span style="--i:3;--c:#f1c40f;"></span>
<span style="--i:4;--c:#e74c3c;"></span>
</div>
</body>
</html>