jquery - Vertically center image if height less than parent.height, else limit height to 100% -


i'm using html5-fullscreen mode full-screen parent div, in want vertically center image, if image smaller parent div (ie. screen size). want limit image max-height = 100% of parent, avoid zooming in if image larger screen.

i can center image 2 divs (one display:table, , other display:table-cell), cannot @ same time set image max-height not more parent div. can latter using position:absolute; max-height:100%; centering doesn't work on smaller images.

example markup:

<div id="fullscreen-container">     <div id="fullscreen-img-wrapper">         <img id="fullscreen-img" src="/images/test-6000x4000.png" />     </div> </div> 

any ideas how can accomplished appreciated!

<style> #fullscreen-img-wrapper { display: table-cell;     margin-left: auto;     margin-right: auto;     vertical-align: middle;     width: 100%; } #fullscreen-img { width:100%; } </style>  <div id="fullscreen-container">     <div id="fullscreen-img-wrapper">         <img id="fullscreen-img" src="/images/test-6000x4000.png" />     </div> </div> 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -