Solved

trying to set td widths with css

Posted on 2013-06-30
6
252 Views
Last Modified: 2013-06-30
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?
0
Comment
Question by:isnoend2001
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 53

Accepted Solution

by:
Scott Fell,  EE MVE earned 500 total points
ID: 39288312
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
 

Author Closing Comment

by:isnoend2001
ID: 39288547
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
 
LVL 53

Expert Comment

by:Scott Fell, EE MVE
ID: 39288591
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:isnoend2001
ID: 39288730
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
 

Author Comment

by:isnoend2001
ID: 39288806
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
 
LVL 53

Expert Comment

by:Scott Fell, EE MVE
ID: 39288808
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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question