0

Currently I have this img html

 <img id="modalImg" alt="img" src="/path">

How can I make this image with overlay background? something like this .background-color: rgba(0,0,0,0.2);

Example:

enter image description here

Pablo
  • 1,357
  • 1
  • 11
  • 40

2 Answers2

0

I'm not sure if i get it correctly, but you can simply do this.

      <div class="img-container" style="position:relative;display:inline-block">
        <img id="modalImg" alt="img" src="https://via.placeholder.com/150">
        <span class="overlay" style="
            display:inline-block;
            position:absolute;
                  top:0px;left:0px;
            width:100%; height:100%;
            background-color: rgba(0,0,0,0.2);
         "></span>
      </div>
Bishoy Romany
  • 26
  • 1
  • 3
-1

I don't totally get want you want to do, but I think by putting a div around the img and setting a padding could do what you want, something like these:

<div style="padding: 10px; background-color: rgba(0,0,0,0.2)">
    <img id="modalImg" alt="img" src="/path">
</div>
Diogo Brito
  • 147
  • 5