Up | Down

 

Centering vertically Text in css

~ ~
CSS level 2 doesn't have a property for centering things vertically. There will probably be one in CSS level 3. But even in CSS2 you can center blocks vertically, by combining a few properties. The trick is to specify that the outer block is to be formatted as a table cell, because the contents of a table cell can be centered vertically.

The example below centers a paragraph inside a block that has a certain given height. A separate example shows a paragraph that is centered vertically in the browser window, because it is inside a block that is absolutely positioned and as tall as the window.

DIV.container {
min-height: 10em;
display: table-cell;
vertical-align: middle }
...

This small paragraph...


Index of demos and downloads

~ ~

Preload animated gif image

~ ~
preload animation gif image download
 
© 2009 - canwecan.com
IniMinimalisKah is proudly powered by Blogger