Solved

Formatting an HTML table with CSS

Posted on 2012-03-14
9
269 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
Industry Leaders: 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Use Images instead of radio button and get the checked value and pass it to a h2 tag 3 41
Fix a css menu for width 15 33
CSS Style Effect 2 18
alert on input text 2 25
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 …
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
In this tutorial viewers will learn how to define a gradient in CSS. Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Gradient. Define the background as "linear-gradient(to right, #ee3668, black)". Ensure you …
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…

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