Vertical centering variable height image while maintaining max-width/height
This should prove to work quite well… no JavaScript necessary 🙂 See the working demo on jsFiddle. CSS /* Don’t Change – Positioning */ .absoluteCenter { margin:auto; position:absolute; top:0; bottom:0; left:0; right:0; } /* Sizing */ img.absoluteCenter { max-height:100%; max-width:100%; } HTML <img class=”absoluteCenter” src=”https://stackoverflow.com/questions/6282968/PATHTOIMAGE”> Note: This class can be used for anything quite easily. … Read more