我可以在同一属性中设置背景图像和不透明度吗? [英] Can I set background image and opacity in the same property?
本文介绍了我可以在同一属性中设置背景图像和不透明度吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以在CSS参考资料中看到如何设置图像透明度和如何设置背景图片.但是,如何结合这两者以设置透明的背景图像?
I can see in CSS references how to set image transparency and how to set a background image. But how can I combine these two in order to set a transparent background image?
我有一张要用作背景的图像,但是它太亮了-我想将不透明度降低到约0.2.我该怎么办?
I have an image that I'd like to use as a background, but it is too bright - I'd like to turn the opacity down to about 0.2. How can I do this?
#main {
background-image: url(/wp-content/uploads/2010/11/tandem.jpg);
}
推荐答案
两种方法:
- 转换为PNG并将原始图像设置为0.2不透明
- (更好的方法)在
#main
之前的<div>
为position: absolute;
,并且高度与#main
相同,然后应用背景图像和opacity: 0.2; filter: alpha(opacity=20);
.
- Convert to PNG and make the original image 0.2 opacity
- (Better method) have a
<div>
that isposition: absolute;
before#main
and the same height as#main
, then apply the background-image andopacity: 0.2; filter: alpha(opacity=20);
.
这篇关于我可以在同一属性中设置背景图像和不透明度吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文