效果如图:
<!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>
html,
body,
.circle {
height: 100%;
display: flex;
align-items: center;
justify-content: center;
background-color: aliceblue;
}
.circle {
width: 10em;
height: 10em;
border-width: 0.4em;
border-style: solid;
border-radius: 50%;
border-left-color: transparent;
border-right-color: transparent;
border-top-color: red;
border-bottom-color: blue;
position: relative;
animation: animate 2s ease-in-out infinite alternate;
}
.circle::before {
content: '';
position: absolute;
width: 75%;
height: 75%;
border-width: 0.4em;
border-style: solid;
border-radius: 50%;
border-left-color: transparent;
border-right-color: transparent;
border-top-color: orange;
border-bottom-color: cyan;
animation: animate 4s ease-in-out infinite alternate;
}
.circle::after {
content: '';
position: absolute;
width: 50%;
height: 50%;
border-width: 0.4em;
border-style: solid;
border-radius: 50%;
border-left-color: transparent;
border-right-color: transparent;
border-top-color: yellow;
border-bottom-color: limegreen;
animation: animate 8s ease-in-out infinite alternate;
}
@keyframes animate {
from {
transform: rotate(0deg);
}
to {
transform: rotate(720deg)
}
}
</style>
</head>
<body>
<div class="circle"></div>
</body>
</html>