Solved

trying to set td widths with css

Posted on 2013-06-30
6
248 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
  • 3
  • 3
6 Comments
 
LVL 52

Accepted Solution

by:
Scott Fell,  EE MVE earned 500 total points
Comment Utility
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
Comment Utility
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 52

Expert Comment

by:Scott Fell, EE MVE
Comment Utility
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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:isnoend2001
Comment Utility
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
Comment Utility
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 52

Expert Comment

by:Scott Fell, EE MVE
Comment Utility
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Unordered lists (HTML ul tags) are very handy to create menus of all types, shapes and sizes.  All it takes is a little knowledge of CSS and the possibilities are endless. First off, you should know the general format for menus created using the …
When applying CSS to your HTML, there are many different ways to select which element(s) the CSS applies to.  Some of these selectors are more commonly known and used than others - Here are the more common ones: #X - Matches an ID of X .X - Matche…
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
In this tutorial viewers will learn how to customize the background color and font color of highlighted text using the ::selection element in CSS Begin by defining the selected text as an element in CSS by typing "::selection": Style the ::selection…

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now