1
I need some "hint" on how to make it work in the pseudo-element ::before
the content
(with image, a photo for example) and a background transparent
, all in the same class. A
someone knows how ?
#minha_classe::before {
position: relative !important;
content: url(photo.jpg) !important;
height: auto;
top: 0%;
left: 0%;
margin-left: -50%; /* meio da imagem */
transform: translate(-50%, -50%);
background-color: rgba(165, 30, 30, 0.7) !important;
background-size: 100% 100%;
width: 1000px;
height: 1000px;
}
You can see in this question that the tag
<img>
does not receive pseudo-element because it is an element of type void, ie is a tag that has no lock type</img>
then the solution would be to place the image inside a div and the pseudo element in the<div>
and not in the<img>
https://answall.com/questions/263040/os-pseudo-elementos-after-e-before-funcionam-em-quais-input-types– hugocsl
Summarizing not to put ::before or ::after right on the img tag, but you can have a div with two backgrounds, one with the image and the other with the middle transparent color on top, or use the pseudo-element in the div with the image in the background, if that’s what you want I can make a basic example for you.
– hugocsl
I don’t understand, could you show me ? I use only a div ?
– user33011
I didn’t understand hugocsl, could you exemplify ? because this example I used above is a Download that I use in opening the web page
– user33011