星空网 > 软件开发 > 网页设计

css3 gradient 渐变

分为linear-gradient(线性渐变)和radial-gradient(径向渐变)。
1.线性渐变在Mozilla 下应用
  语法:-moz-linear-gradient( [<point> || <angle>,]? <stop>, <stop> [, <stop>]* )
  参数;共三个参数,第一个参数表示为线性渐变的方向,top是从上往下,left 是从左到右 如果定义成left top,
  那就是从左上角到右下角。第二个和第三个参数分别是起点颜色和终点颜色。

例如:
  background: -moz-linear-gradient( top,#ccc,#000);

2.线性渐变在Webkit下的应用

  语法:-webkit-linear-gradient( [<point> || <angle>,]? <stop>, <stop> [, <stop>]* )
    //最新发布书写语法
      -webkit-gradient(<type>, <point> [, <radius>]?, <point> [, <radius>]? [, <stop>]*)
    //老式语法书写规则
  参数:-webkit-gradient是webkit引擎对渐变的实现参数,一共有五个。第一个参数表示渐变类型(type),
    可以是linear(线性渐变)或者radial(径向渐变)。第二个参数和第三个参数,都是一对值,分别
    表示渐变起点和终点。这对值可以用坐标形式表示,也可以用关键值表示,比如 left top(左上角)
    和left bottom(左下角)。第四个和第五个参数,分别是两个color-stop函数。color-stop函数接受
    两个参数,第一个表示渐变的位置,0为起点,0.5为中点,1为结束点;第二个表示该点的颜色。
  老式书写方法:background: -webkit-gradient(linear,center top,center bottom,from(#ccc), to(#000));
  新式书写方法:-webkit-linear-gradient(top,#ccc,#000);

3.线性渐变在Oper 下的应用:
  语法:-o-linear-gradient([<point> || <angle>,]? <stop>, <stop> [, <stop>]);
  实例:background: -o-linear-gradient(top,#ccc, #000);

4.线性渐变在Trident(IE)下的应用
  语法:filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0, startColorstr=#1471da, endColorstr=#1C85FB);/*IE<9>*/
    -ms-filter: "progid:DXImageTransform.Microsoft.gradient (GradientType=0, startColorstr=#1471da, endColorstr=#1C85FB)";/*IE8+*/
  IE依靠滤镜实现渐变。startColorstr表示起点的颜色,endColorstr表示终点颜色。
    GradientType表示渐变类型,0为缺省值,表示垂直渐变,1表示水平渐变。

1、开始于center(水平方向)和top(垂直方向)也就是Top → Bottom:
  /* Firefox 3.6+ */
    background: -moz-linear-gradient(top, #ace, #f96);
  /* Safari 4-5, Chrome 1-9 */
  /* -webkit-gradient(, [, ]?, [, ]? [, ]*) */
    background: -webkit-gradient(linear,top,from(#ace),to(#f96));
  /* Safari 5.1+, Chrome 10+ */
    background: -webkit-linear-gradient(top, #ace, #f96);
  /* Opera 11.10+ */
    background: -o-linear-gradient(top, #ace, #f96);

2、始于left(水平方向)和center(垂直方向)也是就Left → Right:
  /* Firefox 3.6+ */
    background: -moz-linear-gradient(left, #ace, #f96);
  /* Safari 5.1+, Chrome 10+ */
    background: -webkit-linear-gradient(left, #ace, #f96);
  /* Opera 11.10+ */
    background: -o-linear-gradient(left, #ace, #f96);

3、起始于left(水平方向)和top(垂直方向):
  background: -moz-linear-gradient(left top, #ace, #f96);
  background: -webkit-linear-gradient(left top, #ace, #f96);
  background: -o-linear-gradient(left top, #ace, #f96);

4、角度(Angle):
  没有角度的示例代码:
    background: -moz-linear-gradient(left, #ace, #f96);
    background: -webkit-linear-gradient(left,#ace,#f96);
    background: -o-linear-gradient(left, #ace, #f96);
  加上30度的角度代码:
    background: -moz-linear-gradient(left 30deg, #ace, #f96);
    background: -webkit-gradient(linear, 0 0, 100% 100%, from(#ace),to(#f96));
    background: -o-linear-gradient(30deg, #ace, #f96);




原标题:css3 gradient 渐变

关键词:CSS

CSS
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

shopee马来卖家:https://www.goluckyvip.com/tag/25040.html
Shopee马来西亚:https://www.goluckyvip.com/tag/25041.html
shopee马来西亚站:https://www.goluckyvip.com/tag/25042.html
shopee马来站:https://www.goluckyvip.com/tag/25043.html
shopee马来站点:https://www.goluckyvip.com/tag/25044.html
shopee买家:https://www.goluckyvip.com/tag/25045.html
从园岭新村到大梅沙海滨总站坐什么车:https://www.vstour.cn/a/363191.html
七月份适合去日本旅游吗 7月份去日本哪里好玩:https://www.vstour.cn/a/363192.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流