Make background image transparent with CSS

I have a scenario where I need a transparent background image, but I do not control the dynamically created images that I use. For this reason, Transparent PNG is out of the question. All children in one div should not be executed and should be fully visible.

I know how to apply transparency to background colors and block level elements, but can you do this for a background image?

+5
source share
3 answers

Setting the opacity of an element with a background is a good start, but you will see that any elements inside whose opacity will be changed will also be transparent.

, , (opacity:0.6; filter:alpha(opacity=60)), .

, :

#container {
    width: 200px;
    postiion: relative;
  }
  
  #semitrans {
    width: 100%; height: 100px;
    background: #f00;
    opacity: 0.6;
    filter:alpha(opacity=60);
  }
  
  #hello {
    width: 100%; height: 100px;
    position: absolute;
    top: 20px; left: 20px;
  }
  
<div id="container">
    <div id="semitrans"></div>
    <p id="hello">Hello World</p>
</div>
Hide result
+3

IE filter:alpha(opacity=50);, opacity:.5
.

+1

. . , , , . , .

, , , z- . , !

+1

All Articles