JSFiddle - React, Tailwind, and code Playground
HTML
<div id="container">
<div>
<img id="img" src="http://lh5.ggpht.com/-J7Q7cUDEFOU/S_bKEoyMSzI/AAAAAAAAGIw/PZJduitsVa0/largeNewGoogleLogoFinalFlat-a.png" />
<div class="overlay" id="top">Overlay top</div>
<div class="overlay" id="bottom">Overlay bottom</div>
</div>
</div>
CSS
#container > div {
position: relative;
}
#container {
background: #333;
display: table-cell;
width: 300px;
height: 200px;
vertical-align: middle;
margin: auto;
}
#img {
max-width: 300px;
max-height: 200px;
display: block;
margin: auto;
}
.overlay {
position: absolute;
opacity: 0.5;
background: red;
width: 100%;
}
#top {
top: 0px;
}
#bottom {
bottom: 0px;
}