Click to See Complete Forum and Search --> : Setting width of columns


lmf232s
07-18-2005, 09:54 AM
I have two tables.
1 table has the had which will remain tacked down(or will not move)
The other table has all the data that i read in from the database.

I have each tables width set to 999px.
I then set each <td>'s width to be the same in each table.

The problem is that they dont match up. The table that has the data from
the DB always seems to have bigger columns and thus the header does not
match up with the data. It looks something like this

<table width=999px>
<tr>
<td width=10px>Customer</td>
<td width=200px>Name</td>
</tr>
</table>

<table width=999px>
<tr>
<td width=10px>Joe Joe Inc</td>
<td width=200px>Chris Meyers</td>
</tr>
</table>

is there a better mesaurement to use then px. Is there a better way to pull this off.

I need to keep the header intack, so that as you scroll the records, the header columns stay in the same place and does not scroll witht the records.

Everything works, its just i cant seem to get the columns to line up correctly.

Any ideas.

teenagekick5
07-18-2005, 10:48 AM
im not too up on tables but...

i never put px on the end of my pixel mesurements and never have a problem - maybe try without it

also - with your tanle set to a width of 999 and your two cells only adding up to 210 maybe reduce the size of your table width

i.e.
<table width="210">
<tr>
<td width="10">Customer</td>
<td width="200">Name</td>
</tr>
</table>

<table width="210">
<tr>
<td width="10">Joe Joe Inc</td>
<td width="200">Chris Meyers</td>
</tr>
</table>


ive not tested this so if it dont work then let me know and ill have a play about

SFADuncan
07-18-2005, 04:29 PM
Teenagekick5 comments are right. Tables always work best of the TD widths always add up to the total amount of table width. (forget px too)

Why 999?

Best to design to "800" for those with 14inch screens.

Or better still why not "100%"


<table width="800">
<tr>
<td width="20%">Customer</td>
<td width="80%">Name</td>
</tr>
</table>

<table width="800">
<tr>
<td width="20%">Joe Joe Inc</td>
<td width="80%">Chris Meyers</td>
</tr>
</table>

lmf232s
07-18-2005, 04:34 PM
well the above code was an example.
There are a total of 19 columns.
Size 999px is as big as i can make it and still print it landscape after that it
goes off the page.

I am currenlty using 100% but 100% will not work for the header as one table
and then the body as another. Currently the header is not stationary so 100% works fine. But if i have one table for the header and one for the data then they will not line up correctly as the data table columns widths are dicticated by the length of text.

When i do 100%, its the size of the data in the columns that seem to dicticate the size of the column. So if the text of the header is say
"Name"
But the size of the name is
"Mr. Joe Junior and Ms James Grey"

Well then the header column will be small and will not line up with the actual
data column.

Not sure if that made sense.

Let me remove the px and see what happens.