Jump to content

Archived

This topic is now archived and is closed to further replies.

anatak

**SOLVED** table center

Recommended Posts

Hello,

I am trying to center a table with CSS but can not get it to do it.
this is the table
If I change (line 3)<table border="0" cellpadding="0" cellspacing="0" class="index">
into
<table border="0" cellpadding="0" cellspacing="0" align="center" class="index">
then it centers but I can not get this to work using css
[code]
<table border="0" cellpadding="0" cellspacing="0" class="frame"><tr><td class="frame">

<table border="0" cellpadding="0" cellspacing="0" class="index">
<tr>
<td class="index_top_left">
top left
</td>
<td class="index_top_main" border="0" cellpadding="0" cellspacing="0">
top mid
</td>
<td class="index_top_right" border="0" cellpadding="0" cellspacing="0">
top right
</td>
</tr>
<tr>
<td class="index_left" VALIGN ="top" border="0" cellpadding="0" cellspacing="0">
mid left
</td>
<td class="index_main" VALIGN="top" border="0" cellpadding="0" cellspacing="0">
mid mid
</td>
<td class="index_right" VALIGN="top" border="0" cellpadding="0" cellspacing="0">
mid right
</td>
</tr>
<tr>
<td class="index" colspan="3" border="0" cellpadding="0" cellspacing="0">
bottom
</td>
</tr>
</table>
[/code]
here is the css
[code]
table.frame
{
width: 100%;
border: 0px none #EEEEEE;
border-spacing: 0px;
background-color: #EEEEEE; /*background-color*/
padding: 2px;
align: center;
}

td.frame
{
color: #000000; /*text color*/
border: 0px none #EEEEEE; /*border style thickness color*/
text-align: center;
vertical-align: middle;
background-color: #EEEEEE;  /*background-color*/
font-size: 12pt; /*font-size*/
}


/*index page table opmaak*/
table.index
{
width: 800px;
border: 0px none #AAAAFF;
border-spacing: 0px;
padding: 0px;
background-color: #EEEEEE;
align: center;
}[/code]

any one knows the solution ?
thanks a lot
anatak

Share this post


Link to post
Share on other sites
I tried to use text-align and that does not work.
Is there anything wrong with this CSS part ?

table.frame
{
width: 100%;
border: 0px none #EEEEEE;
border-spacing: 0px;
background-color: #EEEEEE; /*background-color*/
padding: 2px;
text-align: center;
}

Share this post


Link to post
Share on other sites
Try using auto margins:
margin: 0 auto;

That should center your table. Make sure your table has a width set.

Share this post


Link to post
Share on other sites
Thanks wildteen88
that did the trick.


Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.