css - How do I make contents in the middle box centered vertically? -


how make contents in middle box centered vertically?

http://jsfiddle.net/9pysu/:

html:

<body>     <div id="header">header content</div>     <div id="bodybox">body content</div>     <div id="footer">footer content</div> </body> 

css:

body { } body > div {     border-radius:10px;     border:2px solid #aaa;     padding:10px;     text-align:center; } #header {     position:absolute;     height:50px;     top:10px;     right:10px;     left:10px; } #bodybox {     position:absolute;     right:10px;     top:94px;     bottom:94px;     left:10px;     border-color:#35c12e;     background-color:#f0f4f0; } #footer {     position:absolute;     height:50px;     bottom:10px;     right:10px;     left:10px;     border-color:#b24842; } 

you need add vertical-align. add div wrapper , give display value of table within current div. put div within , give display value of table-cell.

demo http://jsfiddle.net/9pysu/2/

#bodybox div {     display: table;     vertical-align: middle;     height: 100%;     width: 100%; } #bodybox div div {     display: table-cell;     vertical-align: middle;     height: 100%; } 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -