Just use the properties :before or :after, in case, it would be better to :after for example, your code would look like this:
CSS
span{
position:relative;
}
div{
width: 640px;
height: 640px;
opacity: 1;
position: absolute;
}
div:after{
content:'';
position:absolute;
top:0;
bottom:0;
left:0;
right:0;
background-color:rgba(0,0,0,.6);
}
div img{
width:100%;
}
HTML
<span>
<div>
<img src="https://scontent.cdninstagram.com/t51.2885-15/e15/11909170_999395153465997_38853384_n.jpg?ig_cache_key=MTA1NTI1MTUxNDA0OTkxNDkyMg%3D%3D.2" alt="">
</div>
</span>
Now, to explain better, the properties :before and :after serve so that we can control a single element as if they were layers of it, before and after, :after was set as absolute so that we could use the position according to top,left,right e bottom, the span has to be set as relative, because as you know, position absolute responds to the first parent who goes relativo.
Then to set the property :before/:after we need to say, what is the content, hence the content:''; to show that the content is empty and the property is presented to the end user in the correct way, so I give a background-color in the after, and already put the opacidade along with the rgba(0~255,0~255,0~255,0~1).
It’s like I photoshopped a layer above its element, and gave it properties common to an element
Dude, this is a feature of the image, you need to edit it using GIMP, Photoshop..., to achieve this effect. You also need to "color" the background of the "parent" element, where the image is contained. But apparently you are already doing this. So your problem is with the image itself.
– mau humor
@mauhumor the images above is just to illustrate what I want to do with css.
– Gilmar Santos
What exactly do you want to do? That the image takes the "bottom of your site"? or you want to put a semi-transparent layer on top of the image?
– mau humor
I want the image to have a background over it.
– Gilmar Santos
So this is the "right way," I think. This is what they do when they show an image, or advertisement, blocking the rest of the site. But still leaving visible. If you want the image to take what is underneath. Then you would have to edit, as I said before.
– mau humor
@mauhumor, it is not necessary to edit the image in photoshop, it can easily give this effect on the image as shown in my reply :)
– Murilo Melo
In my mind background is what’s behind, in your case is a "background in front"? Don’t want to edit the question and make it clearer?
– Renan Gomes
He used the wrong term, wanted a layer in front, was already doing, but was finding the shape not very good.
– mau humor
Guys, thank you so much for the answers.
– Gilmar Santos