thead & tbody width

R

rukkie

Hi,

I have a "small" problem, with a "big" table. The table consist of 27
cols and a lot of rows. The content of the cells can vary. Every cell
has his defined width="xyzpx". Nevertheless, as some content is larger
than the defined width, the cell is stretched (this is the normal
behaviour I assume and I don't have problems with it ..). But the
problem is that the header cells defined in the thead section are not
equally stretched as it does not know what is happening in the tbody
....So at the end , the header cells do not correspond anymore with the
body cells .... Is there somebody who has solved this kind of problem ?
I want to keep the thead part, because I want it fixed (not scrolling
vertically if there are many rows in the table). Summarized : how can
you keep the thead fixed vertically but having the same horizontal
width as the body cells in the table? Anyone ?
 
J

Jukka K. Korpela

Scripsit rukkie:
I have a "small" problem, with a "big" table. The table consist of 27
cols and a lot of rows.

Post the URL so that we can make suggestions on making the table more
useful. Do you really expect someone to _read_ or otherwise use such a
table?
The content of the cells can vary.

It would be odd if they couldn't.
Every cell has his defined width="xyzpx".

Remove them. You're now using wrong syntax, you're now setting width in
pixels, and you should use width settings (normally in CSS) only to solve
some problems you've observed, instead of using them routinely, just
_creating_ problems.
Nevertheless, as some content is larger
than the defined width,

Apparently that may happen. If you set a cell's width to, say, 60 pixels, it
is quite possible that even a single letter is too wide to fit in. You
remember, don't you, that the user has the final word on font size?
the cell is stretched (this is the normal
behaviour I assume and I don't have problems with it ..).

Fine. And maybe you'll notice that you don't even need to set the width at
all.
But the
problem is that the header cells defined in the thead section are not
equally stretched as it does not know what is happening in the tbody

"It", the browser, knows well what is happening in the tbody, since it does
not format the table until it has read and processed all of it - which is
why it may take some seconds before the user sees the table, even if the
connection is fast.

However you can break this by using table-layout: fixed in CSS. Then you
would need to deal with the consequences, which can be rather bad but do
_not_ included different widths for cells in one column.

Instead, you table structure is probably wrong, so that the header cells are
not recognized as belonging to columns in the intended way. Using a
validator may reveal some syntax errors, but it won't reveal problems like
different number of cells in different rows, which often causes considerable
confusion.

As usual, posting the URL without being asked to do so would have helped you
to get a faster and friendlier response.
...So at the end , the header cells do not correspond anymore with the
body cells ....

You seem to managed to create that problem.
I want to keep the thead part, because I want it fixed (not
scrolling vertically if there are many rows in the table). Summarized
: how can you keep the thead fixed vertically but having the same
horizontal width as the body cells in the table? Anyone ?

Now that's a completely different question. Sorry, but I already spent the
time allocated to responding to your message, when I discussed the problem
that you created when trying to solve the real problem. HTH. HAND.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top