透明的背景,不透明的元素 [英] Transparent background, opaque elements
问题描述
我想在 body
和主要 div
的半透明背景上有图像背景,以便图像可以通过它看到,但阴影。然而,最简单的方法是:
$ body $ {
background-image:...
}
#main {
background-color:#999;
opacity:0.9
}
也会使 #main
也是不透明的,例如任何包含 img
。
你如何做我所描述的?
谢谢 rgba帮助你,但它不被所有浏览器支持
用法:
rgba(a,b,c,d),其中a =红色(0-255); b =绿色(0-255); c =蓝色(0-255),d = alpha不透明度(0-1)
想要50%的红色背景,您应该使用
background:rgba(255,0,0,0.5);
I want to have an image background on body
and a semitransparent background on main div
, so that the image can be seen through it, but shaded. However, the easiest
body {
background-image: ...
}
#main {
background-color: #999;
opacity: 0.9
}
will also make everything within #main
to be opaque as well, such as any contained img
.
How do you do what I describe?
Thanks
rgba helps you, but it is not supported by all browsers
usage:
rgba(a,b,c,d), where a = red(0-255); b = green(0-255); c = blue(0-255), d = alpha opacity(0-1)
so if you want a 50% red background, you should use
background: rgba(255,0,0,0.5);
这篇关于透明的背景,不透明的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!