Friday, June 01, 2007

Vertical alignment in DIV panel

There is no such attribute or style attribute like 'valign' or 'vertical-align' for DIV panels. And 'text-align' only sets the horizontal alignment of a DIV's content. However, if you wish to position the content vertically in the middle, you may use the 'line-height' attribute:

<div style="width: 100px; height: 100px; line-height: 100px; text-align: center; border: 1px solid red;">acontent</div>


content


Special thanks to Erika :).

1 comment:

Lorinczi Zoltan said...

Another way could be using padding settings. Something like this:

div style="width: 6em; padding-top: 2.5em; padding-bottom: 2.5em; text-align: center; border: 1px solid red;"