1 Star 4 Fork 0

前端喵 / 04-页面加载loading动画

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
style.css 1.84 KB
一键复制 编辑 原始数据 按行查看 历史
前端喵 提交于 2020-04-07 20:36 . 仓库初始化
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
width: 100%;
height: 100vh;
background: #222;
/* 实现子元素的垂直水平居中,采用Flex布局 */
display: flex;
align-items: center;
justify-content: center;
}
.container {
display: flex;
}
.container .point{
width: 2em;
height: 2em;
border-radius: 50%; /* 实现圆形 */
background: #fff;
margin: 1em;
user-select: none;
position: relative;
}
.container .point::before {
position: absolute;
content: '';
width: 100%;
height: 100%;
background: inherit; /* 从父元素继承背景颜色 */
border-radius: inherit; /* 从父元素继承圆角 */
animation: wave 2.2s ease-out infinite;
/* 对before元素定义动画,完成时间2s, 采用ease-out过渡,重复循环 */
}
@keyframes wave {
50%,
70% {
transform: scale(2.5);
}
80%,
100% {
opacity: 0;
}
}
/* 设置背景颜色,自行选取五个颜色即可 */
.container .point:nth-child(1) {
background: #7ef9ff;
}
.container .point:nth-child(2) {
background: #89cff0;
}
.container .point:nth-child(3) {
background: #4682b4;
}
.container .point:nth-child(4) {
background: #0f52ba;
}
.container .point:nth-child(5) {
background: #000080;
}
/*
* 现在动画都是同时出现的,而我们需要的是一种逐渐出现的效果
* 所以需要对每个元素的动画加一个延迟
* 最后一个与第一个之间的间隔太短
* 所以需要把整体的动画时间延长一下
*/
.container .point:nth-child(1)::before {
animation-delay: 0s; /* 第一个不需要延迟 */
}
.container .point:nth-child(2)::before {
animation-delay: 0.2s; /* 依次延迟0.2s */
}
.container .point:nth-child(3)::before {
animation-delay: 0.4s;
}
.container .point:nth-child(4)::before {
animation-delay: 0.6s;
}
.container .point:nth-child(5)::before {
animation-delay: 0.8s;
}
1
https://gitee.com/cmdparkour/page_loading_animation.git
git@gitee.com:cmdparkour/page_loading_animation.git
cmdparkour
page_loading_animation
04-页面加载loading动画
master

搜索帮助