Add overlay to image

<!DOCTYPE html>
<html>

<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
.container {
position: relative;
width: 200px;
}

.image {
opacity: 1;
display: block;
width: 100%;
height: auto;
transition: .5s ease;
backface-visibility: hidden;
}

.center {
transition: .5s ease;
opacity: 0;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
text-align: center;
}

.container:hover .image {
opacity: 0.5;
}

.container:hover .center {
opacity: 1;
}

.text {
background-color: #6b2fff;
color: white;
font-size: 9px;
padding: 16px 32px;
}
</style>
</head>

<body>

<h2>make opacity with Box</h2>
<p>Hover over the image to see the effect.</p>

<div class="container">
<img src="https://images.unsplash.com/photo-1564666069679-3e1d55404209" alt="Avatar" class="image"
style="width:200px">
<div class="center">
<div class="text">WOW</div>
</div>
</div>

</body>

</html>

Comments