trying to set td widths with css

I am trying to set this 3 col table <td> widths in this center table
leftcol 99px
centercol: 302px
rightcol: 99px
I added this and now the borders have disappeared:

table.table3col.leftcol td{
width: 99px;
 }
 
table.table3col.rightcol td{
width: 99px;
 }
table.table3col.centercol td{
width: 302px;
 }
this page
http://roofgenius.com/test.asp
how can i fix this?
isnoend2001Asked:
Who is Participating?
 
Scott Fell, EE MVEConnect With a Mentor Developer & EE ModeratorCommented:
Change your css to

#=ID
.=Class

Look at your table and go in order.  The table has an id of table3col then you have a td with a class of leftcol

table#table3col td.leftcol {
width: 99px;
 }
 
table#table3col td.rightcol {
width: 99px;
 }
table#table3col td.centercol {
width: 302px;
 }

Open in new window

0
 
isnoend2001Author Commented:
Thanks
do you know why the cell borders don't show ?
I had them showing until i tried setting the td widths, then they disappeared
0
 
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
Look at your css.  It was kind of messed up.

Take note of what is an ID and what is a Class.   There can only be one ID on a page, but many objects can have the same Class.

If your html reads like
<table id="stuff1">
<tr class="row1"><td class="col1">r1c1</td class="col2"><td>r1c2</td></tr>
<tr class="row2"><td class="col1">r2c1</td class="col2"><td>r2c2</td></tr>
</table>

Open in new window

and you want to target only the 1st row, 2nd column you would use css as follows
table#stuff1 .row1.col2{xxx:xxx;}

Open in new window

0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
isnoend2001Author Commented:
I don't understand mixing classes and id,s as i don't know how many rows, but know how many columns. I am trying to recreate this page with css:
http://roofgenius.com/books.asp
this page uses vbscript to fill the table from an access database in a loop

The books page then opens this page: depending on the id
http://roofgenius.com/bookdetail.asp with an id for the product
After i style these pages I have another 4 pages that are almost the same.
http://roofgenius.com/Product.asp
http://roofgenius.com/Tarps.asp
I was thinking the 3 column  table would be the easy part
0
 
isnoend2001Author Commented:
Seems i was making it more difficult than needs be. I found this code:
table {
width: 100%;
border-collapse: collapse;
border: 1px solid #666666;
}

td.column_1, td.column_3 {
width: 99px;
height: 159px;
border: 1px solid #666666;
text-align: center;
}

td.column_2 {
border: 1px solid #666666;
padding: 4px;
vertical-align:top;
This page only has 1 table
0
 
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
Read up here http://www.w3schools.com/css/css_table.asp and just on css http://www.w3schools.com/css/ and/or https://developer.mozilla.org/en-US/learn/css and/or http://learncss.tutsplus.com/

Taking a break for several hours to read up on this will save you ten fold in a short time.

On the table example I gave you, typically you would not need to put a class on every row or column.  Instead you would just add a class or id to the table and style the td's using code like; table#MyTable {color:red;} and the text will all become red.  Or table#MyTable td td {color:blue;} and the 2nd td will have blue text.

If you run into any other issues, just post another question.   Do try your best to work it out on your own and play with a few different things.  And if you are still stuck or just want confirmation if there could have been a better way, ask.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.