CSS: Center div with dynamic height
Many solutions out there, but this one did exactly what I needed. Centering a div with a variable (hence unknown) height vertically and horizontally.
HTML structure.
CSS.
The original source of this solution contains a couple of IE fallbacks, when needed.
Source: https://css-tricks.com/snippets/css/center-div-with-dynamic-height
HTML structure.
<div id="page"> <div id="content_container"> <p>your content</p> </div> </div>
CSS.
#page{ display:table; height:100%; overflow:hidden; margin:0px auto; } #content_container{ display:table-cell; vertical-align: middle; }
The original source of this solution contains a couple of IE fallbacks, when needed.
Source: https://css-tricks.com/snippets/css/center-div-with-dynamic-height
Comments
Add new comment