Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add color overlay on an image

Tags:

css

So I have an image. I need to put a color overlay rgba(56, 59, 64, 0.7) on top of this image.

HTML:

<div class="home">
   <img src="http://via.placeholder.com/350x150" />
</div>

CSS:

.home img {
  width: 100%;
  padding: 0;
  margin: 0;
}

.home img {
  width: 100%;
  padding: 0;
  margin: 0;
}
    
<div class="home">
   <img src="http://via.placeholder.com/350x150" />
</div>
like image 751
Ali Almohsen Avatar asked Sep 02 '25 02:09

Ali Almohsen


1 Answers

Here you go

.home {

}

img {
  width: 100%;
  padding: 0;
  margin: 0;
  display:block;
}

.wrap {
  position:relative;
}

.wrap:before {
  content:"";
  position: absolute;
  top:0;
  left:0;
  height:100%;
  width:100%;
  background: rgba(0,0,0,0.5);
  z-index:999;
}
<div class="home">
<div class="wrap">
   <img src="http://via.placeholder.com/350x150" />
 </div>
</div>
like image 175
RacoonOnMoon Avatar answered Sep 07 '25 00:09

RacoonOnMoon