新增第91个小实例:旋转的炫光心形loading动画
This commit is contained in:
parent
d01d5f381c
commit
cecc75ee51
|
@ -94,4 +94,5 @@
|
|||
87. HTML5+CSS3+JS小实例:逼真的玻璃卡片悬停效果
|
||||
88. HTML5+CSS3小实例:广告灯牌效果的loading动画
|
||||
89. HTML5+CSS3小实例:自带射灯的浮雕按钮
|
||||
90. HTML5+CSS3小实例:超时空背景的登录界面
|
||||
90. HTML5+CSS3小实例:超时空背景的登录界面
|
||||
91. HTML5+CSS3小实例:旋转的炫光心形loading动画
|
|
@ -0,0 +1,73 @@
|
|||
*{
|
||||
/* 初始化 */
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
body{
|
||||
/* 100%窗口高度 */
|
||||
height: 100vh;
|
||||
/* 弹性布局 水平+垂直居中 */
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
background-color: #111;
|
||||
}
|
||||
.loader{
|
||||
/* 相对定位 */
|
||||
position: relative;
|
||||
/* 执行变色动画 */
|
||||
animation: changeColor 10s linear infinite;
|
||||
}
|
||||
.loader span{
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: -200px;
|
||||
width: 200px;
|
||||
height: 2px;
|
||||
/* 设置旋转的基点位置 */
|
||||
transform-origin: right;
|
||||
/* 通过var函数调用自定义属性--i,计算每一个span元素的旋转角度 */
|
||||
transform: rotate(calc(18deg * var(--i)));
|
||||
}
|
||||
.loader span::before{
|
||||
content: "";
|
||||
/* 绝对定位 */
|
||||
position: absolute;
|
||||
left: 0;
|
||||
width: 15px;
|
||||
height: 15px;
|
||||
border-radius: 50%;
|
||||
/* 自定义属性--c(颜色值) */
|
||||
--c:gold;
|
||||
background-color: var(--c);
|
||||
/* 阴影(发光效果) */
|
||||
box-shadow: 0 0 10px var(--c),
|
||||
0 0 20px var(--c),
|
||||
0 0 40px var(--c),
|
||||
0 0 60px var(--c),
|
||||
0 0 80px var(--c),
|
||||
0 0 100px var(--c);
|
||||
/* 执行动画:动画名 时长 线性的 无线播放 */
|
||||
animation: animate 2s linear infinite;
|
||||
/* 计算并设置动画延迟时间 */
|
||||
animation-delay: calc(-0.1s * var(--i));
|
||||
}
|
||||
|
||||
/* 定义动画 */
|
||||
@keyframes animate {
|
||||
0%{
|
||||
transform: translateX(0) scale(0.5);
|
||||
}
|
||||
50%{
|
||||
transform: translateX(200px) scale(1);
|
||||
}
|
||||
100%{
|
||||
transform: translateX(0) scale(0.5);
|
||||
}
|
||||
}
|
||||
@keyframes changeColor {
|
||||
to{
|
||||
/* 颜色滤镜 */
|
||||
filter: hue-rotate(1000deg);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
<!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/91.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="loader">
|
||||
<!-- --i为自定义属性,CSS中通过var函数对其调用 -->
|
||||
<span style="--i:1;"></span>
|
||||
<span style="--i:2;"></span>
|
||||
<span style="--i:3;"></span>
|
||||
<span style="--i:4;"></span>
|
||||
<span style="--i:5;"></span>
|
||||
<span style="--i:6;"></span>
|
||||
<span style="--i:7;"></span>
|
||||
<span style="--i:8;"></span>
|
||||
<span style="--i:9;"></span>
|
||||
<span style="--i:10;"></span>
|
||||
<span style="--i:11;"></span>
|
||||
<span style="--i:12;"></span>
|
||||
<span style="--i:13;"></span>
|
||||
<span style="--i:14;"></span>
|
||||
<span style="--i:15;"></span>
|
||||
<span style="--i:16;"></span>
|
||||
<span style="--i:17;"></span>
|
||||
<span style="--i:18;"></span>
|
||||
<span style="--i:19;"></span>
|
||||
<span style="--i:20;"></span>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
Loading…
Reference in New Issue