CSS vertical align
- Started
- Last post
- 13 Responses
- ukit
I have a set of divs that are set to float left inside a container div. Is there any way at all that I can get the inner divs to vertical-align to the middle? This is driving me crazy...
- van_rijn0
#whatever {
vertical-align: middle;
}work?
- IRNlun60
yeah this one is tricky especially if you want it to work in most browsers....
you can try using a line-height equal to the height of the div...
try googling it... there’s a few techniques for this...
- acescence0
i think IE ignores vertical-align
- acescence0
position:relative; top:50%;
- thismanslife0
It's generally not quite that simple, but it's not difficult... it depends on a few things... like, the height of the container div. I'll mock up a quick example... BRB :)
- thismanslife0
http://www.thismanslife.co.uk/te…
...checked in IE5,6,7beta and FF1.5 on PC XP.
*Should* work on Mac browsers too...!
- ukit0
Thanks thismanslife! This seems like an elegant and workable solution for many cases. Unfortunately, all my inner divs need to be set to float, so I don't think position: absolute will work. I swear, just when I think I know CSS pretty well..some little random thing and it takes 3 hours to solve.
- thismanslife0
Hmmm, why do they *need* to be set to float?
- acescence0
works fine with position: relative and floats:
- caseyc0
Get over it and use a table. Why hack something so simple? Semantic markup? Please.
:)
- Point50
caseyc, my ears are burning!!! a table?! zomg...
using a table is like buying your latte from 7-11
- airey0
works on mac firefox NOT on mac safari.
- monNom0
use a table and go get a latte on the other end of the city to use up all the extra time you now have.