CSS 使引导程序半透明

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18274976/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 23:59:19  来源:igfitidea点击:

Make bootstrap well semi transparent

csstwitter-bootstrap

提问by SoWhat

I tried to make the bootstrap well semi transparent by adding opacity:0.4but this results in making the text semitransparent as well. Is there any way to make the well semi transparent without making the body lose opacity as well.

我试图通过添加使引导程序半透明,opacity:0.4但这也会导致文本半透明。有什么方法可以使井半透明而不使身体也失去不透明度。

回答by Hieu Le

Change the background-colorinstead of changing its opacity

改变background-color而不是改变它opacity

.well {
   background-color: rgba(245, 245, 245, 0.4);
}

With a notice that the value 245comes from the default background-colorof the .wellclass: #F5F5F5.

随着公告称,值245来自默认background-color的的.well类:#F5F5F5

回答by Kees Sonnema

There's an awesome way of doing this. You can do it using rgbaand 'background-color` like this:

有一种很棒的方法可以做到这一点。你可以rgba像这样使用和 'background-color`来做到这一点:

.well{
background-color: rgba(255,255,255,0.4); // I don't know the .well color, so I used white as example
}

where the 0.4is the opacity and the 255,255,255 the color codes in rgb.

其中0.4是不透明度,255,255,255 是 rgb 中的颜色代码。

More about rgba:

更多关于RGBA:

http://www.css3.info/preview/rgba/

http://www.css3.info/preview/rgba/