前端 - css中关于设置透明度的问题,有点混乱
天蓬老师
天蓬老师 2017-04-17 11:23:11
0
4
663

background:#000;
opacity:0.8;
filter:alpha(opacity=80);
background:rgba(255,255,255,0.8);
弄不清楚这几个的关系

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all(4)
迷茫

background:#000Set background:

opacity:0.5;Set transparency, but it will affect child nodes:

filter:alpha(opacity=80); Mainly used for image processing and filters.

css3filter

background:rgba(0,0,0,0.5);Set background transparency, which will not affect child nodes

Peter_Zhu

Add to the accepted answer above:

  1. background:#000; and background:rgba(255,255,255,0.8);: Both are background background attributes, but the values ​​are expressed in different ways. #000 and rgba(255,255,255,0.8) are two different attribute values. The former is a hexadecimal value and the latter is an rgba value. a=alpha is used to represent opacity. 0.8 is written as .8 which is more professional. rgba is a new method added to CSS3, so pay attention to compatibility. Other commonly used color value methods include rgb. For more details, you can see the color value on the w3c official website. I am too lazy to post the link.

  2. filter:alpha(opacity=80); and opacity:0.8;: Both can be used to set opacity. The former is a private attribute filter of IE. Because IE is not compatible with the latter writing method, the filter method is used to disguise it. To achieve the purpose of setting opacity.

Ty80

background:rgba(0,0,0,0.5); sets background transparency and will not affect child nodes

伊谢尔伦

More precisely, background-color:#FFF; is better than background: #FFFThis abbreviation of background is more suitable for background :url(path) center center no-repeat This kind of.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template