I have been able to show a description when hovering over an image while having the image stay centered and responsive to scaling thanks to How to show text on image when hovering?. However, when I attempt to scale out too much the description begins to escape the boundaries of the image it's supposed to overlay.
Here's the code responsible for the above. Any suggestions are welcome.
HTML
<div class= "img__wrap">
<img src="Capture.JPG" alt= "Website"/>
<p class= "img__description">The website you're on!</p>
</div>
CSS
img {
display: block;
margin: 0 auto;
max-width: 100%;
height: auto;
}
.img__wrap {
position: relative;
max-width: 100%;
height: auto;
}
.img__description {
position: absolute;
bottom: 0;
left: 0;
right: 0;
background: #544f50;
color: #fff;
visibility: hidden;
opacity: 0;
padding: 10%;
transition: opacity .2s, visibility .2s;
}
.img__wrap:hover .img__description {
visibility: visible;
opacity: 0.75;
}