上个效果我理解错误,搞成了整个圆边都是渐变的线条,实际上要的是渐变的颜色,就把上次的代码改了一点。
先上代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>circle</title>
<style type="text/css">
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
margin: 0;
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
background-color: #eee;
}
.box {
width: 200px;
height: 200px;
display: flex;
justify-content: center;
align-items: center;
background-color: transparent;
}
.line {
width: 200px;
height: 200px;
padding: 3px;
display: flex;
justify-content: center;
align-items: center;
border-radius: 50%;
background: rgb(0, 191, 255);
background: linear-gradient(0deg, rgba(0, 191, 255, 0.1) 33%, rgba(0, 191, 255, 1) 100%);
animation: animate 1.2s linear infinite normal;
}
.cover {
width: 100%;
height: 100%;
background-color: #eee;
border-radius: 50%;
}
@keyframes animate {
to {
transform: rotate(1turn);
}
}
</style>
</head>
<body>
<div class="box">
<div class="line">
<div class="cover"></div>
</div>
</div>
</body>
</html>
再看效果
结束
颜色什么的可以自行去修改。把 .cover 这个 div 去掉就可以知道为什么是个渐变色的环,也可以更好的修改成需要的颜色。