>  기사  >  웹 프론트엔드  >  使用css3背景渐变中的透明度来设置不同颜色的背景渐变 - jimmie.Mr

使用css3背景渐变中的透明度来设置不同颜色的背景渐变 - jimmie.Mr

WBOY
WBOY원래의
2016-05-20 16:50:501520검색

为了添加透明度,我们使用 rgba() 函数来定义颜色结点。rgba() 函数中的最后一个参数可以是从 0 到 1 的值,它定义了颜色的透明度:0 表示完全透明,1 表示完全不透明。rgba()后面的百分比表示位置。

具体代码:

<span style="color: #800000;">background: -webkit-linear-gradient(top, rgba(255,255,255,0.4)0%, rgba(255,255,255,0.2)75%, rgba(255,255,255,0)98%);</span><span style="color: #008000;">/*</span><span style="color: #008000;"> Safari、Chrome </span><span style="color: #008000;">*/</span><span style="color: #800000;">

background: -o-linear-gradient(bottom, rgba(255,255,255,0.4)0%, rgba(255,255,255,0.2)75%, rgba(255,255,255,0)98%);</span><span style="color: #008000;">/*</span><span style="color: #008000;"> Opera </span><span style="color: #008000;">*/</span><span style="color: #800000;">

background: -moz-linear-gradient(bottom, rgba(255,255,255,0.4)0%, rgba(255,255,255,0.2)75%, rgba(255,255,255,0)98%);</span><span style="color: #008000;">/*</span><span style="color: #008000;"> Firefox </span><span style="color: #008000;">*/</span><span style="color: #800000;">

background: linear-gradient(to bottom, rgba(255,255,255,0.4)0%, rgba(255,255,255,0.2)75%, rgba(255,255,255,0)98%); </span><span style="color: #008000;">/*</span><span style="color: #008000;"> 标准的语法(必须放在最后) </span><span style="color: #008000;">*/</span>

 

注意:Internet Explorer 9 及之前的版本不支持渐变。

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.