你的位置:首页 > 软件开发 > 网页设计 > CSS3 渐变背景色各种方向 兼容IE9+

CSS3 渐变背景色各种方向 兼容IE9+

发布时间:2017-09-05 22:00:16
背景色,除了纯色以外,还能够使用多种颜色组合成为渐变背景色,使页面丰富。渐变背景分为两种:1、线性渐变;2、环形渐变; 线性渐变线性渐变分为:横向、纵向、对角渐变三种渐变语法:<linear-gradient> = linear-gradient([ [ &l ...

背景色,除了纯色以外,还能够使用多种颜色组合成为渐变背景色,使页面丰富。

渐变背景分为两种:

1、线性渐变;

2、环形渐变;

 

线性渐变

线性渐变分为:横向、纵向、对角渐变三种渐变

语法

<linear-gradient> = linear-gradient([ [ <angle>| to <aside-or-corner> ] ,]? <color-stop>[, <color-stop>]+)

<side-or-corner> = [left | right] || [top | bottom]

<color-stop> = <color> [ <length> | <percentage>  ]?

<angle>:用角度值指定渐变的方向。

to left:设置渐变为从右到左;

to right:设置渐变为从左到右;

to top:设置渐变为从下到上;

to bottom:设置渐变为从上到下;

<color-stop>:设置指定渐变的起止颜色

<color>:指定颜色

<length>:用长度值指定起止色位置。不允许负值

<percentage>:用百分比指定起止色位置。

 

background:linear-gradient(参数1,参数2,参数3,参数4....参数N)

参数1:可填可不填,填写的话写方向 如:to right,就是渐变方向由左到右,不填写默认从上到下渐变。

参数1':与参数1基本一致,写在-webkit-,-moz-,-o-前缀情况下,如:left 代表渐变方向开始的位置

参数2:渐变开始颜色,可填rgba()或者#fff或者white,后面加百分比代表颜色占比多少,如 #fff 50% 代表白色占比50%。

参数3:若后面无参数 则为渐变终止颜色,与参数2属性可选一致。

参数4....参数N:可增加的渐变颜色节点。最后一个为渐变终止颜色

 

示例

linear-gradient(#fff, #75aaa3);

linear-gradient(to bottom, #fff,#75aaa3);

linear-gradient(to top, #75aaa3, #fff);

linear-gradient(180deg, #fff, #75aaa3);

linear-gradient(to bottom, #fff 0%, #75aaa3 100%);

但是,还需要兼容浏览器:

//从下至上

#text.btt{background: -webkit-linear-gradient(bottom,#fff, #75aaa2);background: -o-linear-gradient(bottom,#fff, #75aaa2);background: -moz-linear-gradient(bottom,#fff, #75aaa2);background: linear-gradient(to top,#fff, #75aaa2); /* 标准的语法(必须放在最后) */} CSS3 渐变背景色各种方向 兼容IE9+

//带透明度

#text.opac{background: -webkit-linear-gradient(rgba(256,256,256,0), #75aaa2);background: -o-linear-gradient(rgba(256,256,256,0), #75aaa2);background: -moz-linear-gradient(rgba(256,256,256,0), #75aaa2);background: linear-gradient(rgba(256,256,256,0), #75aaa2); /* 标准的语法(必须放在最后) */}CSS3 渐变背景色各种方向 兼容IE9+

 

原标题:CSS3 渐变背景色各种方向 兼容IE9+

关键词:CSS

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