实现loading…动画
思路:
- 画个正方形box
- 令相邻两个边框颜色变成蓝色
- border-radius:50%把正方形变成圆形
- 添加animation属性 让它转起来
<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8" />
<title>loading</title>
<head>
<style>
body{
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh; /* 100%,没有元素也会被撑开*/
}
.loading{
max-width: 30%;
line-height: 1.4;
font-size: 1.2rem;
text-align: center;
font-weight: bold;
}
.loading__author{
color: darkgray;
font-size: 1rem;
display: block; /*将inline元素span变成块级元素,让其独占一行*/
margin-bottom: 30px;
}
.loading__anim{
width: 35px;
height: 35px;
display: inline-block;
/*将inline元素span变成行内块级元素,若变成块级元素block,独占一行,
宽度与父级元素一致,导致方块不会在中间*/
border: 5px solid rgba(189,189,189 ,0.25); /*灰色5px元素的边框*/
border-left-color: dodgerblue; /*让两边边框颜色变成蓝色*/
border-top-color:dodgerblue;/*让两边边框颜色变成蓝色*/
border-radius: 50%;
animation: ro 600ms linear infinite;
/*linear这个单词不要写错了!!血泪教训!!!!!*/
}
/*Safari and Chrome要加上-webkit-*/
@keyframes ro {
0%{
-webkit-transform:rotate(0deg);
}
25%{
-webkit-transform:rotate(90deg);
}
50%{
-webkit-transform:rotate(180deg);
}
75%{
-webkit-transform:rotate(270deg);
}
100%{
-webkit-transform:rotate(360deg);
}
}
</style>
</head>
<body>
<section class="loading">
<p>For new sidebar colors, click your workspace name, then Preferences > Sidebar > Theme</p>
<span class="loading__author">- Your friends at Slack</span>
<span class="loading__anim"></span>
</section>
</body>
</html>