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:
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>
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>