Solved

trying to set td widths with css

Posted on 2013-06-30
6
250 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
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 52

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
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 

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 52

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
css help with menu spacing 10 47
Syntax Error 2 67
bootstrap footer centering and expand problems 7 47
Testing Responsiveness for Different Devices 4 29
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
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 style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…

825 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