王新阳

wangxinyang

CSS3之gradient渐变

线性渐变 point: top从上到下、left从左到右、left top左上到右下、top right右上到左下;angle角度
-linear-gradient( [<point> || <angle>,]? <stop>, <stop> [, <stop>]* )
径向渐变-基本不用 point除了线性渐变的值外,径向梯度允许你指定渐变的形状(圆形circle或椭圆形)和大小(最近端,最近角,最远端,最远角,包含或覆盖 (closest-side, closest-corner, farthest-side, farthest-corner, contain or cover))
-radial-gradient( [<point> || <angle>,]? <stop>, <stop> [, <stop>]* )
重复渐变
repeating-radial-gradient
浏览器兼容写法
-webkit-linear-gradient()
-moz-linear-gradient()
-ms-linear-gradient()
-o-linear-gradient()
linear-gradient()
例
background-image:linear-gradient(to top, #000, #fff, #eee);
background-image:-webkit-linear-gradient(top, #000, #fff, #eee);
background-image:-webkit-linear-gradient(30deg, #000, #fff, #eee);

background: -moz-repeating-linear-gradient(-45deg, #ace, #ace 5px, #f96 5px, #f96 10px);
background: -webkit-repeating-linear-gradient(-45deg, #ace, #ace 5px, #f96 5px, #f96 10px);

更复杂的效果见:http://www.w3cplus.com/node/44

2015-08-02
2024-05-21 星期二 农历四月十四