Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

CSS Forum


You are currently viewing our CSS Forum as a guest. Please register to participate.
Login



Reply
Problem with th / td widths
Old 10-08-2010, 03:49 PM Problem with th / td widths
pealo86's Avatar
Super Spam Talker

Posts: 876
Name: Matt Pealing
Location: England, north west
Trades: 0
I'm trying to style a table with CSS and having a nightmare doing so:
http://bit.ly/ccxu3V

I thought <td> and <th> elements always stayed 'in line' with each other? But the 3 <th> elements are not resizing based on the cells below them.

Also, I've set:
Code:
<th class="first" colspan="2">
On the first <th>, but it just seems to be ignoring the colspan completely!

Does anyone have any ideas what might be wrong?

Thanks
__________________

Please login or register to view this content. Registration is FREE
pealo86 is offline
Reply With Quote
View Public Profile Visit pealo86's homepage!
 
 
Register now for full access!
Old 10-08-2010, 08:15 PM Re: Problem with th / td widths
metho's Avatar
Ultra Talker

Posts: 481
Location: Gold Coast - Brisbane QLD, Australia
Trades: 0
Strange behaviour - can you post a link or an example?
__________________
I do
Please login or register to view this content. Registration is FREE
based.
Spend a lot of time in
Please login or register to view this content. Registration is FREE
.
And
Please login or register to view this content. Registration is FREE
chews up the rest.
metho is offline
Reply With Quote
View Public Profile Visit metho's homepage!
 
Old 10-08-2010, 08:25 PM Re: Problem with th / td widths
pealo86's Avatar
Super Spam Talker

Posts: 876
Name: Matt Pealing
Location: England, north west
Trades: 0
Yup, see the bit.ly link above.

Cheers.
__________________

Please login or register to view this content. Registration is FREE
pealo86 is offline
Reply With Quote
View Public Profile Visit pealo86's homepage!
 
Old 10-08-2010, 09:21 PM Re: Problem with th / td widths
metho's Avatar
Ultra Talker

Posts: 481
Location: Gold Coast - Brisbane QLD, Australia
Trades: 0
bortram.css line 58, get rid of tr display:block;
__________________
I do
Please login or register to view this content. Registration is FREE
based.
Spend a lot of time in
Please login or register to view this content. Registration is FREE
.
And
Please login or register to view this content. Registration is FREE
chews up the rest.
metho is offline
Reply With Quote
View Public Profile Visit metho's homepage!
 
Old 10-09-2010, 10:17 AM Re: Problem with th / td widths
pealo86's Avatar
Super Spam Talker

Posts: 876
Name: Matt Pealing
Location: England, north west
Trades: 0
Thanks that appears to fix the colspan issue etc, but then no matter what widths I apply to any <tr> elements they seem to be completely ignored! When I need them to stretch the full width of the containing <div>

Hmmmm
__________________

Please login or register to view this content. Registration is FREE
pealo86 is offline
Reply With Quote
View Public Profile Visit pealo86's homepage!
 
Old 10-09-2010, 02:44 PM Re: Problem with th / td widths
serandfae's Avatar
Do the "Evil Nanner" !!!

Posts: 9,007
Name: Tim Daily
Location: Apex, NC, US, Sol 3
Trades: 0
Hooray! Someone's actually using a table for what it's intended for--data!

A colspan of 2, when the rest of your table has four data elements per row, will automatically squish your header to what? The first two columns. Make sense?

And, actually, you only apply colspan to a <td> that you want to take up more than one column. Otherwise, the <td>s naturally follow how many blocks you're putting in the grid.

You also didn't put a table opening in there.

tim
__________________
SEO "experts" smell like Big Fish_|_
Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Last edited by serandfae; 10-09-2010 at 07:17 PM.. Reason: correction
serandfae is offline
Reply With Quote
View Public Profile Visit serandfae's homepage!
 
Old 10-09-2010, 06:52 PM Re: Problem with th / td widths
metho's Avatar
Ultra Talker

Posts: 481
Location: Gold Coast - Brisbane QLD, Australia
Trades: 0
what are you talking about serandfae? <tr><th>---</th></tr> is perfectly valid markup! th is a table header cell, not row.

The correct markup for a table header row is:-
Code:
<table>
  <thead>
    <tr>
      <th>Header cell</th>
    </tr>
  </thead>
</table>
pealo86: tr cannot have width. Apply width to table instead. If you want tr's to have differing widths, then you shouldn't use tables.

The parent container, #container .grid_12 has a width of 700px. A width applied to .grid_12 table of 100% will make the table expand to fill the width of .grid_12 minus border, padding and margin:-

.grid_12 table { width: 100%; }
__________________
I do
Please login or register to view this content. Registration is FREE
based.
Spend a lot of time in
Please login or register to view this content. Registration is FREE
.
And
Please login or register to view this content. Registration is FREE
chews up the rest.
metho is offline
Reply With Quote
View Public Profile Visit metho's homepage!
 
Old 10-09-2010, 07:28 PM Re: Problem with th / td widths
serandfae's Avatar
Do the "Evil Nanner" !!!

Posts: 9,007
Name: Tim Daily
Location: Apex, NC, US, Sol 3
Trades: 0
Corrected, regarding the <th>, by the way, <thead>, <tbody>, <tfoot> aren't universally supported. Why add in markup for fluff's sake?

There's nothing wrong with the remainder, and the most important thing: Where's the opening element for the table? What he's asking is why the headers aren't going above the things they're supposed to be over. Answer, old school: Put an empty cell in before the headings, take out the colspan, position within the cells as necessary, done.

tim
__________________
SEO "experts" smell like Big Fish_|_
Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

serandfae is offline
Reply With Quote
View Public Profile Visit serandfae's homepage!
 
Old 10-09-2010, 08:01 PM Re: Problem with th / td widths
metho's Avatar
Ultra Talker

Posts: 481
Location: Gold Coast - Brisbane QLD, Australia
Trades: 0
It's not fluff, it's semantic html. A data table usually has a row of column names that place the data that follows into context, the table header.

What I would like to know is how that page validates as xhtml WITHOUT the opening table tag. Is the opening table tag optional I wonder?

http://validator.w3.org/check?verbos...%2Ffor-sale%2F
__________________
I do
Please login or register to view this content. Registration is FREE
based.
Spend a lot of time in
Please login or register to view this content. Registration is FREE
.
And
Please login or register to view this content. Registration is FREE
chews up the rest.
metho is offline
Reply With Quote
View Public Profile Visit metho's homepage!
 
Old 10-11-2010, 04:26 AM Re: Problem with th / td widths
CSM
CSM's Avatar
Front-End Developer

Posts: 297
Name: Michael Pehl
Location: Palma de Mallorca
Trades: 0
No, <table> tag is necessary. Without <table> it is not valid code.
__________________
Chief Web Officer / Front-End Developer / System Engineer

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
CSM is offline
Reply With Quote
View Public Profile Visit CSM's homepage!
 
Old 10-11-2010, 11:42 AM Re: Problem with th / td widths
serandfae's Avatar
Do the "Evil Nanner" !!!

Posts: 9,007
Name: Tim Daily
Location: Apex, NC, US, Sol 3
Trades: 0
It did validate, though, but it shouldn't have. Probably a glitch in the validator, maybe it associated the open div with the closing for the table, but that's a guess.

However, even if all the markup was semantically correct, that does not mean that everything will function how you want it to. Validation is a tool to help you along, nothing more.

<table> is indeed necessary, and the likely culprit of the odd behavior, and the rest of the solution is still: Put an empty cell in before the headings, take out the colspan, position within the cells as necessary.

tim
__________________
SEO "experts" smell like Big Fish_|_
Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

serandfae is offline
Reply With Quote
View Public Profile Visit serandfae's homepage!
 
Old 10-12-2010, 04:25 AM Re: Problem with th / td widths
Banned

Posts: 408
Name: mushget
Trades: 0
Can you post a link.
mushget is offline
Reply With Quote
View Public Profile Visit mushget's homepage!
 
Old 10-13-2010, 09:50 AM Re: Problem with th / td widths
pealo86's Avatar
Super Spam Talker

Posts: 876
Name: Matt Pealing
Location: England, north west
Trades: 0
Thanks for the tips. I managed to style it using <thead>, <tbody> tags etc.

Although with regards to the <table> opening tag, it is in there But in my code view in FF it's shifted to the right, so you might have missed it.
__________________

Please login or register to view this content. Registration is FREE
pealo86 is offline
Reply With Quote
View Public Profile Visit pealo86's homepage!
 
Old 10-13-2010, 11:16 AM Re: Problem with th / td widths
metho's Avatar
Ultra Talker

Posts: 481
Location: Gold Coast - Brisbane QLD, Australia
Trades: 0
Glad u got it sorted. It's a good looking table. Could use some very subtle alternating row background colours though....
__________________
I do
Please login or register to view this content. Registration is FREE
based.
Spend a lot of time in
Please login or register to view this content. Registration is FREE
.
And
Please login or register to view this content. Registration is FREE
chews up the rest.
metho is offline
Reply With Quote
View Public Profile Visit metho's homepage!
 
Reply     « Reply to Problem with th / td widths
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 2.42092 seconds with 12 queries