我有一些DIV,有一些改变div背景图片的不透明度
文字和背景图片。我想减少背景图像的不透明度。但是,当我将不透明度应用于DIV时,会影响DIV中的文本。如何在不更改DIV中文本的不透明度的情况下更改背景图片的不透明度?我有这个代码,我从另一个问题在stackoverflow,我用它来减少另一个div的不透明度,但我不知道如何修改它来实现上述问题。
function convertHex(hex,opacity){
hex = hex.replace('#','');
r = parseInt(hex.substring(0,2), 16);
g = parseInt(hex.substring(2,4), 16);
b = parseInt(hex.substring(4,6), 16);
result = 'rgba('+r+','+g+','+b+','+opacity/100+')';
return result;
}
$(".add_to_cart_button").click(function() {
$(".cart-contents").css("background-color",convertHex('#f47d32',40));
});
此主题在这里覆盖:http://stackoverflow.com/questions/4183948/css-set-background-image-with-opacity –
是图片动态还是静态?如果是静态的,可以在Photoshop或类似软件中减少不透明度,然后将其另存为.PNG。 请注意,这只是其中一个选项。 – harisdev
也相关:[设置背景图像的不透明度而不影响子元素](http://stackoverflow.com/questions/4997493/set-opacity-of-background-image-without-affecting-child-elements) – showdev