css 怎么设置颜色为rgba啊

html-css014

css 怎么设置颜色为rgba啊,第1张

在css中使用rgba(255, 255, 255, 0.5)这样的格式来表示rgha。其中最后一个参数表示Alpha通道,表示透明度。

例如:给两个div添加一样的背景色设置不同的透明度

代码:

<div class="div1">rgba透明度0.4</div>

<div class="div2">rgba透明度0.6</div>

css:

div{

margin:10px auto

width:200px

height:100px

text-align: center

line-height: 90px

}

.div1{background: rgba(83,172,150,0.4)}

.div2{background: rgba(83,172,150,0.8)}

效果:

css的背景颜色设置为无色步骤如下:

1、新建一个html文件,需要设置宽度250px和高度140px,以及背景色填充为红色。

2、然后在父级DIV中插入一个子DIV,定义它的宽200px,高90px,以及背景色。

3、然后添加一个无色(透明)的代码(opacity:0.6)。

4、在图层的上方,有个不透明度,设置为60%。

5、把刚才的背景色和无色代码删除,换个代码【background-color:rgba(255,255,255,0.6)】。

6、其中255,255,255就是PS中的拾色器里的数值。这样,css的背景颜色就为无色了。