I have a div
that has a background-image
, I would like its hover effect to change its opacity without affecting the child element, in this case the <p>
. I have seen similar answers to my question, but having a background does not work the answers. opacity to an element with background affects the children, I only want to affect the father
How can I solve that?
<div class="container_img">
<p>
this is a text
</p>
</div>
.container_img{
position:relative;
border:1px solid red;
margin-top:-14px;
display: table;
margin-top:2px;
width: 709px;
height: 141px;
background-image: url("https://i.imgur.com/VBOZfaY.png");
background-image: url("https://i.imgur.com/VBOZfaY.png");
background-repeat: no-repeat;
background-size: 100% 100%;
}
.container_img:hover{
background-color: transparent;
opacity:0.5;
}
this is my code: