线性渐变
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>线性渐变</title>
<style>
.border1{
width: 200px;
height: 200px;
margin: 100px;
position: relative;
border-radius:200px;
background: white;
}
.border1::after{
position: absolute;
top: -40px;
bottom: -40px;
left: -40px;
right: -40px;
background: linear-gradient(to right,blue, yellow);
content: '';
z-index: -1;
border-radius: 200px;
}
</style>
</head>
<body>
<div class="border1"></div>
</body>
</html>
旋转渐变
<!DOCTYPE html>
<html>
<head>
<title>旋转渐变</title>
<style>
@keyframes moveover {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
.box {
position: relative;
width: 100px;
height: 100px;
animation: moveover 3s linear infinite;
}
.box::before {
content: "";
position: absolute;
width: 50px;
height: 100px;
border-radius: 50px 0 0 50px;
background: linear-gradient(blue, yellow);
z-index: 2;
}
.box2 {
position: absolute;
width: 50px;
height: 100px;
border-radius: 0 50px 50px 0;
left: 50%;
background: linear-gradient(blue, yellow);
z-index: 1;
}
.box::after {
content: "";
position: absolute;
width: 92px;
height: 92px;
top: 4px;
left: 4px;
border-radius: 50%;
background-color: #fff;
z-index: 2;
}
</style>
</head>
<body>
<div class='box'>
<div class="box2"></div>
</div>
</body>
</html>