效果图:
注意:startColorstr = #ff0000, endColorstr = #000000) 的颜色值不能简写成f00,否则渐变颜色不对。
<style>
.test{
background:-moz-linear-gradient(top,#f00,#000);
background:-webkit-linear-gradient(top,#f00,#000);
background:-ms-linear-gradient(top,#f00,#000); /*IE9以上版本才支持;*/
background:-o-linear-gradient(top,#f00,#000);
background:linear-gradient(top,#f00,#000);
-ms-filter:"progid:DXImageTransform.Microsoft.gradient(gradientType = 0, startColorstr = #ff0000, endColorstr = #000000)"; /*IE8.0 版本可以识别*/
/*针对IE6 IE7设置纯色背景色;*/
/*+background:#ccc; */
}
/*GradientType=0表示从上到下的渐变,GradientType=1表示从左到右的渐变,startColorstr开始颜色,endColorstr结束颜色*/
.test{
width:100px;height:60px;
}
</style>
<div class="test">
</div>