代码语言:javascript复制
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
div{
width: 400px;
height: 400px;
border:2px solid #abcdef;
margin:50px;
}
.box1{
background-image: linear-gradient(to right,red,yellow);
}
.box2{
background-image: linear-gradient(to right,red 50%,yellow 50%);
}
.box3{
background-image: linear-gradient(to right,red 100px,yellow 300px);
}
.box4{
background-image: linear-gradient(red 200px,green 300px,blue 400px);
}
.box5{
background-image: linear-gradient(to top,red,rgba(0,0,0,0),yellow);
}
.box6{
background-image: linear-gradient(to top,red,transparent,yellow);
}
</style>
</head>
<body>
<div class="box1"></div>
<div class="box2"></div>
<div class="box3"></div>
<div class="box4"></div>
<div class="box5"></div>
<div class="box6"></div>
</body>
</html>