知识点
- border-top-color:设置上边框的颜色
- top,left,bottom,right同时指定数值,注意不设置width和height时,会相对与父元素的上下左右存在相同的距离,这样可以实现垂直水平居中。相当于等比例缩放的效果,查看相关博客,大佬博客
效果
Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="index.css">
</head>
<body>
<div></div>
</body>
</html>
*{
margin: 0;
padding: 0;
}
body{
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: rgb(29, 20, 20);
}
div{
height: 100px;
width: 100px;
border: 3px solid transparent;
border-top-color: rgba(13, 113, 228, 0.877);
border-radius: 50%;
position: relative;
animation: donghua 2.4s linear infinite;
}
div::before{
content: "";
position: absolute;
top: 4px;
left: 4px;
right: 4px;
bottom: 4px;
border: 3px solid transparent;
border-top-color: rgba(245, 80, 3, 0.904);
border-radius: 50%;
animation: donghua 2s linear infinite;
}
div::after{
content: "";
position: absolute;
top: 10px;
left: 10px;
right: 10px;
bottom: 10px;
border: 3px solid transparent;
border-top-color: rgba(55, 217, 245, 0.897);
border-radius: 50%;
animation: donghua 2.3s linear infinite;
}
@keyframes donghua{
0%{
transform: rotate(0);
}
100%{
transform: rotate(720deg);
}
}