Solved

trying to set td widths with css

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
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…
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…

733 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