Re: CSS Top panel

Originally Posted by
Dead-i
@essellar - The reason I recommended tables was because if you do text-align:center on a DIV, it will just center the text inside instead of the DIV itself. Also, tables give you the flexibility of creating multiple cells side by side.
I understand your point though: There may be no need for a table if you only need one cell, since tables are tables
Horizontally centering a div in its containing element is easy. For any browser that's reasonably modern, it's simply a matter of using:
Code:
margin: <some value for vertical> auto;
... and the div is centered. If you need to support ancient versions of Internet Explorer (version 5.5 and below, IIRC, or maybe that includes 6, which I haven't supported for years), you can use this old trick:
Code:
left: 50%;
margin-left: -<half the horizontal size>;
Negative margins are legal. That trick, then, puts the "home box" of the div in a position where the left edge of the box is centered, then uses a negative margin to pull the left edge of the "display box" back to a centered position. Again, centering content (both the boxes and the content of the boxes) is trivial. And creating "multiple cells side by side" is also incredibly easy with non-tabular block elements. There is no excuse for using tables for something like this. None.
Last edited by essellar; 09-04-2011 at 02:41 PM.
Reason: fixed bbcode tag
“Beware of bugs in the above code; I have only proved it correct, not tried it.” --Donald Knuth
"It was as if its architects were given a perfectly good hammer and gleefully replied, 'neat! With this hammer, we can build a tool that can pound in nails.'" -- Alex Papadimoulis (on TheDailyWTF.com)