...

View Full Version : CSS, table centering



Shivandragon
12-16-2002, 04:28 PM
Can someone help me out?

http://users.skynet.be/shivand/EMC/

I need to center that table, so the larger the screenresolution is, the larger both black sides become ... How can I do this with CSS, cause i don t get i fixed

Thx

ShivanD

Shivandragon
12-16-2002, 05:07 PM
this table:

<div style=" ??????? ">
<table border="0" cellpadding="0" cellspacing="0" width="768" height="458">
<tr>
<td background="images/LeftUpper.jpg" height="54" width="178">&nbsp;</td>
<td background="images/Upper.jpg" width="401" height="54">&nbsp;</td>
<td background="images/RightUpper.jpg" width="189" height="54">&nbsp;</td>
</tr>
<tr>
<td background="images/Left.jpg" width="178" height="339">&nbsp;</td>
<td bgcolor="#000000"> <div class="Content">
<p>terssssskjlkjsqlkjlksqdjlqkjdsq</p>
<p>lksqdlmkmlkmsdql</p>
<p>mlksqdmlkmlkqsd</p>
<p>qsdlkmlksdq</p>
<p>sqkjlksdqj</p>
<p>sqdlkjqsd</p>
<p>&nbsp; </p>
</div>
</td>
<td background="images/emcTemplate_r2_c4.jpg" width="183" height="339">&nbsp;</td>
</tr>
<tr>
<td background="images/LeftUnder.jpg" width="178" height="65">&nbsp;</td>
<td background="images/Under.jpg" height="65" width="401">&nbsp;</td>
<td background="images/RightUnder.jpg" height="65" width="189">&nbsp;</td>
</tr>
</table>
</div>

Kiwi
12-16-2002, 05:16 PM
<div style="text-align: center;">
<!-- table here -->
</div>

cg9com
12-16-2002, 05:31 PM
does that work in every browser, i am at work so i cant check, but i seem to remember having problems centering my table with the div element like that.

Shivandragon
12-16-2002, 05:35 PM
aight i fixed it, thx dude

Kiwi
12-16-2002, 05:53 PM
Not sure about all broswers. It does with IE5+ and NS6/Moz. Oh, I forgot to mention, you might need to re-do the text align in the child elements. They should inherit the text-align from the parent (although tables don't do this very often).

cg9com
12-18-2002, 03:04 PM
wont work crossbrowser in xhtml11 markup (strict) in ie6/win for me

Shivandragon
12-18-2002, 04:59 PM
Originally posted by cg9com
wont work crossbrowser in xhtml11 markup (strict) in ie6/win for me what?
:o

jkd
12-18-2002, 05:07 PM
table {
margin: 0 auto;
}


A table is a block-level element, and therefore should not be affected by text-align. text-align centering block elements was a BUG in IE's rendering model, and is fixed in strict mode rendering in IE6.

margin: 0 auto;

Is the correct way of centering any block level element through CSS.

Shivandragon
12-18-2002, 05:14 PM
why (margin: 0 auto)

2 values??

cg9com
12-18-2002, 05:59 PM
thanks jkd

jkd
12-18-2002, 07:54 PM
Originally posted by Shivandragon
why (margin: 0 auto)

2 values??

margin: allmargins
margin: topbottommargin leftrightmargin
margin: topmargin rightmargin bottommargin leftmargin

Can't say
margin: auto;
because auto isn't correct for vertical margins
margin: 0 auto;
gives it 0 vertical margins, and centers it horizontally
margin: 0 auto 0 auto;
also works

You could also say:
margin-left: auto;
margin-right: auto;

Shivandragon
12-19-2002, 02:15 PM
thx for your time and explenation...

Greetz

ShivanD



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum