代码不好看,但兼容所有A-Grade浏览器:
.linearbox{ background: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#dddddd)); background: -moz-linear-gradient(top, #fff, #dddddd); background: -ms-linear-gradient(top, #ffffff, #e3e3e3); background: -o-linear-gradient(top, #fff, #dddddd); filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#dddddd'); background: linear-gradient( #fff, #dddddd); /* 原 background: linear-gradient(top, #fff, #dddddd);的写法(添加top)不被浏览器支持 */ } .test{ background:-moz-linear-gradient(#fff,#333); background:-webkit-gradient(linear,center top,center bottom,from(#fff),to(#333)); background:-webkit-linear-gradient(#fff,#333); background:-o-linear-gradient(#fff,#333); background:-ms-linear-gradient(#fff,#333); background:linear-gradient(#fff,#333); } .test2{ background:-moz-linear-gradient(#000,#f00 50%,#090); background:-webkit-gradient(linear,center top,center bottom,from(#000),color-stop(.5,#f00),to(#090)); background:-webkit-linear-gradient(#000,#f00 50%,#090); background:-o-linear-gradient(#000,#f00 50%,#090); background:-ms-linear-gradient(#000,#f00 50%,#090); background:linear-gradient(#000,#f00 50%,#090); } .test3{ background:-moz-linear-gradient(left center,#000 20%,#f00 50%,#090 80%); background:-webkit-gradient(linear,left center,right center,color-stop(.2,#000),color-stop(.5,#f00),color-stop(.8,#090)); background:-webkit-linear-gradient(0deg,#000 20%,#f00 50%,#090 80%); background:-o-linear-gradient(0deg,#000 20%,#f00 50%,#090 80%); background:-ms-linear-gradient(0deg,#000 20%,#f00 50%,#090 80%); background:linear-gradient(0deg,#000 20%,#f00 50%,#090 80%); } .test4{ background:-moz-linear-gradient(45deg,#000,#f00 50%,#090); background:-webkit-gradient(linear,left bottom,right top,from(#000),color-stop(.5,#f00),to(#090)); background:-webkit-linear-gradient(45deg,#000,#f00 50%,#090); background:-o-linear-gradient(45deg,#000,#f00 50%,#090); background:-ms-linear-gradient(45deg,#000,#f00 50%,#090); background:linear-gradient(45deg,#000,#f00 50%,#090); }
A级浏览器A-Grade browsers是YUI对浏览器的一个等级划分。
关于浏览器等级划分,查看Yahoo Yui 官网信息