代码语言:javascript复制
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>线性渐变-linear gradient</title>
<link rel="stylesheet" type="text/css" href="css/reset.css"/>
<style type="text/css">
.container{
width: 960px;
margin:100px auto;
border:1px solid #f00;
}
.container div{
font:20px arial;
float:left;
width: 200px;
height: 200px;
border:2px solid gray;
text-align:center;
line-height: 200px;
margin:20px;
}
.box1{
background-image:linear-gradient(to top,yellow,red);/*往top的方向走,黄 红*/
}
.box2{
background-image:linear-gradient(0deg,yellow,red);/*0deg(top)是在div的最上面,意思是往top的方向走,黄 红*/
}
.box3{
background-image: linear-gradient(360deg,yellow,red);/*top的意思。黄红。360deg原来的地方*/
}
.box4{
background-image: linear-gradient(-360deg,yellow,red);/*还是原来的方向,只不过是逆时针走的。*/
}
.box5{
background-image: linear-gradient(to bottom,yellow,red);/*往下走,yellow red*/
}
.box6{
background-image: linear-gradient(180deg,yellow,red);/*bottom的意思,是说往下走,黄色 红色*/
}
.box7{
background-image: linear-gradient(360deg,yellow,red);
}
.box8{
background-image: linear-gradient(to right,yellow,red);/*往右走,黄 红*/
}
.box9{
background-image: linear-gradient(90deg,yellow,red);/*往右走,黄 红*/
}
.box10{
background-image: linear-gradient(-270deg,yellow,red);/*逆时针走270deg,到了90deg的方向了。往右走,黄 红*/
}
</style>
</head>
<body>
<div class="container clearfix">
<div class="box1">to top</div>
<div class="box2">0deg</div>
<div class="box3">360deg</div>
<div class="box4">-360deg</div>
<div class="box5">to bottom</div>
<div class="box6">180deg</div>
<div class="box7">360deg</div>
<div class="box8">to right</div>
<div class="box9">90deg</div>
<div class="box10">270deg</div>
<div class="box11">to left</div>
<div class="box12">-90deg</div>
<div class="box13">270deg</div>
</div>
</body>
</html>