Solved

Formatting an HTML table with CSS

Posted on 2012-03-14
9
270 Views
Last Modified: 2012-03-29
Hello, I'm working on a CSS script to format a table. My challenge here is that the table in question is generated with a rule engine product, and the fastest way for me to place some formatting in the table is thru CSS. So far, I have only added a border to the table and added collapsible borders to the rows and columns. What I would like to do, is have the column's width adjust according to the content. Can this be done?

Thanks...
0
Comment
Question by:horalia
[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
  • 6
  • 3
9 Comments
 
LVL 3

Expert Comment

by:MikeyLLB
ID: 37722111
In the CSS try setting "column-width: auto;"
0
 

Author Comment

by:horalia
ID: 37722140
Didn't work... This is the CSS code I have so far:

      #ReviewTable{
            border:1px solid #C6C6C6;
            margin:2px 70px;
            border-collapse: collapse;
            column-width:auto
      }
      #ReviewTable td {
            font-size:1em;
            border:1px solid
            border-collapse:collapse;
            padding:3x 7px 2px 7px;
            column-width:auto
      }
0
 
LVL 3

Expert Comment

by:MikeyLLB
ID: 37722168
Try using just "width:auto;" and also set "white-space: nowrap;"
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!

 
LVL 3

Expert Comment

by:MikeyLLB
ID: 37722179
Also, you are missing a ";" after your border property in the TD style group.
0
 
LVL 3

Accepted Solution

by:
MikeyLLB earned 500 total points
ID: 37722237
#ReviewTable{
	border: 1px solid #C6C6C6;
	margin: 2px 70px;
	border-collapse: collapse;
	column-width: auto
}

#ReviewTable td {
	font-size: 1em;
	border: 1px solid;
	border-collapse: collapse;
	padding: 3x 7px 2px 7px;
	column-width: auto;
	white-space: nowrap;
}

Open in new window


This seems to work for me.

http://mjco.me.uk/test/
0
 
LVL 3

Expert Comment

by:MikeyLLB
ID: 37722255
Also, you may want to specify the border colour in the TD group rather than the Table group.
0
 

Author Comment

by:horalia
ID: 37722605
Not working yet... And I also just realized I have another issue as I was applying these changes to the other tables.... In the table, I have set some javascript to hide the contents of the row if the row doesn't have an answer... Well, the row is hidden, but not the borders. So, when a few rows are hidden, a thicker gray line appears in its place. Would you have any idea how to fix this?
0
 
LVL 3

Expert Comment

by:MikeyLLB
ID: 37722621
can you post an archive of the complete code. Looking at partial html/css makes it difficult to find the issue.
0
 

Author Closing Comment

by:horalia
ID: 37782567
I decided to use a different route to create the table, unfortunately, this being an HTML driven code, there's not a lot I can do with just CSS. I appreciate your time and award you the points. Thank you.
0

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

As a result of several questions about how to use Bootstrap I thought it would be a good idea to write down the development aspect of creating a Bootstrapped website in as little time as possible. Part 1 of this article will only concentrate on g…
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…

705 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