I have an image, and I want that when I hover over the image a black background with little opacity cover the image and a button on top of the image appear. Write now I put the button in the place where I want to but I can't make it disappear and appear when I hover.
<div class="container">
<img src="img_snow.jpg" alt="Snow">
<button class="btn">Button</button>
</div>
.container {
position: relative;
button {
position: absolute;
top: 60%;
left: 50%;
transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
}
button:hover {
background-color: black;
}
}
img {
background-image: url(${({ src }) => src});
background-repeat: no-repeat;
background-size: cover;
&:hover {
background-color: #000;
opacity: 0.5;
}
}