Solved

Formatting an HTML table with CSS

Posted on 2012-03-14
9
267 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
  • 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
 
LVL 3

Expert Comment

by:MikeyLLB
ID: 37722179
Also, you are missing a ";" after your border property in the TD style group.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

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…
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 style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
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…

760 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

18 Experts available now in Live!

Get 1:1 Help Now