|
Posted by Ben C on 03/20/07 15:50
On 2007-03-20, Spartaco <boh@boh.voh> wrote:
> Hi, this is a big problem for me I can't solve it: I have a <div>, and I
> want the content of this div be vertically aligned in the middle by applying
> CSS styles to the div tag... I've tried the vertical-align but it does not
> work, the content is always at the top.
vertical-align aligns the inline contents of the div with respect to the
lines they're on, not with respect to the total height of the div.
You could set line-height on the div to the div's own height, but if the
lines break you will get an unwanted effect.
Your best option may be to use a table cell instead of a div (or apply
display: table-cell to the div). vertical-align on a table cell means
what you expect.
Navigation:
[Reply to this message]
|