JSFiddle - React, Tailwind, and code Playground
HTML
<div data-content="Here is some text added on hover via a content value of attr(data-content)" class="image">
<img src="http://i.stack.imgur.com/Sjsbh.jpg" alt="" />
</div>
<hr>
<div data-content="More text.. as you can see, this approach works with multiple images" class="image">
<img src="http://i.stack.imgur.com/Sjsbh.jpg" alt="" />
</div>
CSS
.image {
position:relative;
width:200px;
height:200px;
}
.image img {
width:100%;
vertical-align:top;
}
.image:after {
content: attr(data-content);
color:#fff;
position:absolute;
width:100%; height:100%;
top:0; left:0;
background:rgba(0,0,0,0.6);
opacity:0;
transition: all 0.5s;
-webkit-transition: all 0.5s;
}
.image:hover:after {
opacity:1;
}