半透明div中的非透明图像

时间:2015-05-07 11:58:59

标签: jquery css

CSS

.popup {
    z-index: 10000;
    filter: alpha(opacity=40); 
    -moz-opacity: .40;
    background-color: #000000;
}

HTML

<div class="popup" style="display: none; overflow: auto;">
    <img  src="~/image.png" /> <!--it also becomes transparent. -->
</div>

我不想让图片透明。有什么帮助吗?

1 个答案:

答案 0 :(得分:2)

尝试为background-color而不是opacity设置透明度,如下所示

background-color:rgba(255,0,0,0.5); //0.5 is the transparency you are setting for color

了解更多信息,请参阅 Article