[thelist] vertical aligning a div contents with css

Joseph A Borg jacborg at mac.com
Sun Sep 29 13:21:01 CDT 2002


On Thursday, September 26, 2002, at 11:14 PM, Eduardo Dominguez wrote:

> Am I missing something ?

advice to try at your own risk;-) this is how i would tackle it:

vertical-align works on a line of text not on the content block (div in
this case.)
Let me explain: if you had a line of text with inline elements of
variable height it would align the shtuff to top/center?/bottom... of
the highest inline element.
Thus if you add an empty inline element (span?) with same height of
enclosing div, you should get going. In my case I had an <img> as first
item so that helped me, then the text was enclosed in a span with
vertical align set to top/bottom.
If you need an arbitrary verical alignment, set the span's leading (line
spacing) to the best pixel value required and set vertical alignment to
top.

hope this helps. I would love  to hear of any problems with the above
kludge/reasoning.




More information about the thelist mailing list