html - Center DIV Horizontally and Vertically -


i have html structure:

<div class="metaboxdet">     <div class="metd">         <h1>hello world!</h1>     </div> </div> 

http://jsfiddle.net/fvuel00n/2/

the problem here cant center div "metd" horizontally , vertically. have tried adjusting top, bottom, left , right return not accurate results. there way can center horizontally , vertically dynamically.

please check fiddle here see in action. thanks!

as discussed in answer, can add helper element height:100% , display:inline-block vertical-align:middle, , change container display:inline-block vertical-align:middle

.helper{     display:inline-block;     height:100%;     vertical-align:middle; } /*container*/ .metd{     vertical-align:middle;     display:inline-block; } 

here's code in action


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -