After extensive research, I have come across numerous solutions to this issue, but none of them have proven effective in my specific scenario. Here is a JSFiddle link illustrating the problem at hand:
http://jsfiddle.net/kr394ye2/1/
.classA {
background-color: yellow;
width: 50px;
height: 50px;
float: left;
}
.classB {
width: auto;
height: auto;
max-width: 50px;
max-height: 50px;
}
<div class="classA">
<img class="classB" src="https://www.google.com/logos/doodles/2015/ida-b-wells-153rd-birthday-4853060954226688-hp.jpg"></img>
</div>
I am attempting to center an image both horizontally and vertically within its containing div, with the image automatically adjusting to fit the size of the div. It is important that the image remains an inline element and not a background.
Various methods such as using auto margins, display properties, text-align, vertical-align, and even the center tag have all been attempted without success.
An ideal solution would effectively center the image both horizontally and vertically within the div.