Home  >  Article  >  Web Front-end  >  使用css3背景渐变中的透明度来设置不同颜色的背景渐变 - jimmie.Mr

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

WBOY
WBOYOriginal
2016-05-20 16:50:501498browse

为了添加透明度,我们使用 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 及之前的版本不支持渐变。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn