3 ms·
Many times when you want to constrain an element's size and/or alignment based on the size/alignment of elements above/below and beside it, you need to use tabl
by briansmith 18y ago
Many times when you want to constrain an element's size and/or alignment based on the size/alignment of elements above/below and beside it, you need to use table layout. Consider a simple layout from a site I will be launching very soon (not to scale):
BBBB
A BBBB
BBBB
CCCCCDDDDEEEEE
CCCCCDDDDEEEEE
FFFF
FFFF
FFFF
You want A to be vertically centered with B and horizontally centered with C. You can't give a fixed width or a fixed height to anything because the layout needs to be fluid. I don't see how to do it without using table layout.
If some dimensions of some elements can be fixed (e.g. the width of A and C), or if some alignments are changed to make thinks convenient (e.g. align the bottom of A with the bottom of B), of if approximate alignment is good enough, then often nested block/inline-block and some positioning fu can be used instead of tables. But, sometimes the automatic table layout algorithm is exactly what the layout needs.