Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add low-key (black, transparent overlay) effect to image using CSS?

this is the effect I want

I am trying to make an image looks like it is kind of transparent? I don't really know how to describe it but it is like you can write texts on it and the image is in the back.

is this doable with css or javascript or any other language?

like image 371
Kat Avatar asked Jan 28 '17 17:01

Kat


People also ask

How do I add a black overlay to an image in CSS?

You needed to put the :hover on image, and make the . overlay cover the whole image by adding right:0; and bottom:0 .

How do you put an overlay effect on an image in CSS?

In short, CSS overlay effects are achieved by using the following: background-image and background CSS properties to add image and linear-gradient overlay effect. position:absolute , top , bottom , right , left CSS properties to control the position of overlay image or text.


2 Answers

I think what you need is a css filter.

For the very latest browsers check out these examples which use:

img {
   -webkit-filter: brightness(20%);
    filter:brightness(20%);
}

For older browsers check out these examples which use:

img {
    opacity: 0.3;
    filter: alpha(opacity=50); /* For IE8 and earlier */
}
like image 177
Matthew Cawley Avatar answered Nov 14 '22 23:11

Matthew Cawley


You can add a mask over the image like the one below:

html:

<div>
<img scr="yourImage.jpg" alt="" />
<div class="mask"></div>
</div>

css:

.mask{
position:absolute;
width:100%;
height:100%;
background:rgba(0,0,0,0.3);
}
like image 38
creativenitish Avatar answered Nov 14 '22 23:11

creativenitish