If you have a div containing a table, and you want to center the table, and you want it to work in both IE and FF, you have to use ugly -moz-center hack. Is there a better way? And why does this even exist? Why does FF not support normal center in this case. Example code below. -moz-center needed for FF, line below it needed for IE:
Two Column Liquid Layout
#center-test {
text-align:-moz-center;
#text-align:center;
}
cell 1
Jonahx wrote:If you have a
If you have a div containing a table, and you want to center the table, and you want it to work in both IE and FF, you have to use ugly -moz-center hack.
Says who? Just give the table a width and margin: 0 auto.
Tyssen wrote:Jonahx wrote:If
Jonahx wrote:If you have a div containing a table, and you want to center the table, and you want it to work in both IE and FF, you have to use ugly -moz-center hack.
Says who? Just give the table a width and margin: 0 auto.
Cool that is certainly better. Technically though, why do you need to do that? Why doesn't it work without that and a normal "text-align:center"?
Thanks,
Jonah
Because text-align applies
Because text-align applies to, um, text? Actually, inline data. Are you running in quirks mode? IE6+ in standards mode treats text-align correctly.
Many of the -moz- proprietary properties are meant for internal use. For example, in the default html stylesheet;
ul, menu, dir { display: block; list-style-type: disc; margin: 1em 0; -moz-padding-start: 40px; }
The -moz-padding-start is a shorthand for pad left if text is ltr, and pad right if text is rtl.
cheers,
gary
Tyssen wrote:Jonahx wrote:If
Jonahx wrote:If you have a div containing a table, and you want to center the table, and you want it to work in both IE and FF, you have to use ugly -moz-center hack.
Says who? Just give the table a width and margin: 0 auto.
You don't even have to give the table an explicit width. Tables shrink-wrap their content, so have an implicit width.
cheers,
gary
Thanks Gary. Makes sense.
Thanks Gary. Makes sense.
EDIT: Oh one more question. If you do margin: auto auto, why does it not center vertically as well as horizontally?
I don't know. I've read
I don't know. I've read some technical explanations of why vertical auto margin isn't feasible, but don't remember any details. I just accept it doesn't work that way.
cheers,
gary