前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >css3 gradient 渐变

css3 gradient 渐变

作者头像
用户1197315
发布2018-01-19 17:33:46
6320
发布2018-01-19 17:33:46
举报
文章被收录于专栏:柠檬先生柠檬先生

分为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);

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2016-02-04 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档