我可以在同一个属性中设置背景图像和不透明度吗? [英] Can I set background image and opacity in the same property?
本文介绍了我可以在同一个属性中设置背景图像和不透明度吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以在 CSS 参考中看到 如何设置图像透明度 和 如何设置背景图片.但是如何将这两者结合起来以设置透明背景图像?
我有一张图片想用作背景,但它太亮了 - 我想将不透明度降低到 0.2 左右.我该怎么做?
#main {背景图片:网址(/wp-content/uploads/2010/11/tandem.jpg);}
解决方案
两种方法:
- 转换为 PNG 并使原始图像的不透明度为 0.2
- (更好的方法)在
#main
之前有一个,它是position: absolute;
并且与的高度相同>#main
,然后应用背景图像和opacity: 0.2;过滤器:alpha(opacity=20);
.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?
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); }
解决方案Two methods:
- 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屋!
查看全文