效果演示

实现原理
- 通过2个伪元素来设置3条颜色边框
- 通过定位将3个圆弧边框层叠再一起,再通过旋转实现一个圆的效果
- 再给loading添加旋转动画即可
- 要实现文字转动的效果,只需让其反向旋转即可
实现代码
<div class="loading"> <span>loading...</span> </div>
@keyframes rotate {
100%{
transform: rotateZ(360deg);
}
}
@keyframes rotate_ni {
100%{
transform: rotateZ(-360deg);
}
}
body {
margin: 0;
padding: 0;
background-color: black;
}
.loading {
position: relative;
width: 200px;
height: 200px;
box-sizing: border-box;
border-radius: 50%;
border-top: 10px solid #74b9ff;
animation: rotate 2s linear infinite;
margin: 100px auto;
}
.loading::before,.loading::after {
content: '';
width: 200px;
height: 200px;
position: absolute;
left: 0;
top: -10px;
box-sizing: border-box;
border-radius: 50%;
}
.loading::before {
border-top: 10px solid #a29bfe;
transform: rotate(120deg);
}
.loading::after {
border-top: 10px solid #55efc4 ;
transform: rotate(240deg);
}
span {
position: absolute;
color: snow;
width: 200px;
height: 200px;
text-align: center;
line-height: 200px;
animation: rotate_ni 2s linear infinite;
}
完整代码
<!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">
<title>Document</title>
<style>
@keyframes rotate {
100%{
transform: rotateZ(360deg);
}
}
@keyframes rotate_ni {
100%{
transform: rotateZ(-360deg);
}
}
body {
margin: 0;
padding: 0;
background-color: black;
}
.loading {
position: relative;
width: 200px;
height: 200px;
box-sizing: border-box;
border-radius: 50%;
border-top: 10px solid #74b9ff;
animation: rotate 2s linear infinite;
margin: 100px auto;
}
.loading::before,.loading::after {
content: '';
width: 200px;
height: 200px;
position: absolute;
left: 0;
top: -10px;
box-sizing: border-box;
border-radius: 50%;
}
.loading::before {
border-top: 10px solid #a29bfe;
transform: rotate(120deg);
}
.loading::after {
border-top: 10px solid #55efc4 ;
transform: rotate(240deg);
}
span {
position: absolute;
color: snow;
width: 200px;
height: 200px;
text-align: center;
line-height: 200px;
animation: rotate_ni 2s linear infinite;
}
</style>
</head>
<body>
<div class="loading">
<span>loading...</span>
</div>
</body>
</html>
© 版权声明
本站网络名称:
青鹿云
本站永久网址:
www.milubk.com
网站侵权说明:
本网站的文章部分内容可能来源于网络,仅供大家学习与参考,如有侵权请联系站长删除处理。
1 本站一切资源不代表本站立场,并不代表本站赞同其观点和对其真实性负责。
2 本站一律禁止以任何方式发布或转载任何违法的相关信息,访客发现请向站长举报
3 本站资源大多存储在云盘,如发现链接失效,请联系我们我们会第一时间更新。
1 本站一切资源不代表本站立场,并不代表本站赞同其观点和对其真实性负责。
2 本站一律禁止以任何方式发布或转载任何违法的相关信息,访客发现请向站长举报
3 本站资源大多存储在云盘,如发现链接失效,请联系我们我们会第一时间更新。
THE END
暂无评论内容