JSFiddle - React, Tailwind, and code Playground
by joplomacedo
HTML
<div class="img__wrap">
<img class="img__img" src="https://via.placeholder.com/150" />
<div class="img__description_layer">
<p class="img__description">This image looks super neat.</p>
</div>
</div>
CSS
/* quick reset and base styles */
* {
margin: 0;
padding: 0;
border: 0;
}
html {
font-family: helvetica, arial, sans-serif;
}
/* relevant styles */
.img__wrap {
position: relative;
display: inline-block;
}
.img__img {
vertical-align: bottom;
}
.img__description_layer {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: rgba(36, 62, 206, 0.6);
color: #fff;
visibility: hidden;
opacity: 0;
display: flex;
align-items: center;
justify-content: center;
/* transition effect. not necessary */
transition: opacity .2s, visibility .2s;
}
.img__wrap:hover .img__description_layer {
visibility: visible;
opacity: 1;
}
.img__description {
transition: .2s;
transform: translateY(1em);
}
.img__wrap:hover .img__description {
transform: translateY(0);
}