61 lines
1.4 KiB
CSS
61 lines
1.4 KiB
CSS
*{
|
||
/* 初始化 */
|
||
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);
|
||
}
|
||
} |