I need assistance with centering an image both vertically and horizontally inside a div. Here is the current structure:
CSS:
.imgWrapper {
background-color: #000;
height: 100%;
min-height: 480px;
position: relative;
text-align: center;
-webkit-user-select: none;
float: left;
}
.imgStg {
cursor: pointer;
display: block;
font-size: 0;
height: 100%;
min-height: 402px;
position: relative;
text-align: center;
width: 100%;
}
.imgStg img {
display: inline-block;
height: auto;
max-height: 100%;
max-width: 100%;
vertical-align: middle;
width: auto;
text-align: center;
}
HTML:
<div class="imgWrapper" style="width: 724px;line-height: 601px;">
<div class="imgStg">
<img src="http://placehold.it/500x300" style="width: 500px;height: 300px;"/>
</div>
</div>
*Please note that the height of 601px is specified in a parent element
Despite my efforts, the image appears aligned to the top of the div when viewed on localhost in Google Chrome and Firefox. However, it displays correctly in the provided fiddle link. What could be causing this discrepancy?
Screenshot of the issue: