使div透明但不是

时间:2017-07-03 20:36:49

标签: html css image background

我希望有一个内部有图像的div,但div和背景完全透明,给人的印象是图像单独存在,div背景后面的元素出现。

我尝试过以多种方式使用rgba,例如background: rgba(204, 204, 204, 0.5);但是当设置为完全透明时,所有这些都会在div上留下白色背景。

我该如何实现?

EDIT 这是一张图片: This is a crop of the UI screen. The red button is the image and the white is the div backgroud.

如何让红色按钮显示为正常,但能够看到白色部分背后的内容?

我的HTML就是这样:

<div id="transparent-background">
    <img src="./images/ui/chat.gif" class="arrow-button"/>
</div>

谢谢,

1 个答案:

答案 0 :(得分:2)

只需将此CSS用于DIV:

#transparent-background {
  background: transparent;
}
相关问题