Solved

trouble aligning text in a table

Posted on 2013-05-14
2
140 Views
Last Modified: 2013-05-14
http://roofgenius.com/tablepractise.asp

I have been trying to center align all the text in the right side of this table to no avail
also the bottom left 4 rows I have been unable to put a 40px padding on the left side of the left aligned text
What am i doing wrong?
0
Comment
Question by:isnoend2001
2 Comments
 
LVL 40

Accepted Solution

by:
Kyle Abrahams earned 500 total points
ID: 39164745
the <!-- isn't a valid comment for CSS.

use the /* syntax for that.
http://www.w3schools.com/css/css_syntax.asp

I've posted 2 sections of code, the first where everything is working, but the comments are incorrect (actually causing some of your styles not to apply)

The second is the correct syntax, but then other stuff changes.

A useful tool is firefox's inspection tool where you can just right click on a cell to see what styles are being applied.

To indent the text, use a span inside of the cell.


Working:
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="dcterms.created" content="Mon, 13 May 2013 15:47:28 GMT">
    <meta name="description" content="">
    <meta name="keywords" content="">
    <title>Table practise</title>
    
    <!--[if IE]>
    <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
	<style type= "text/css">
	    
	     .nailsizetable .rightcolumn{
	 width: 45px;
	 text-align: center !important;
	  }  
	  
	  	 .nailsizetable .leftcolumn td{
	 width: 345px;
	 text-align:center;
	 margin-left:40px;
	  } 
	  
	
	
	.nailsizetable {
	width:480px; 
    margin:auto;
    font-size:12px;
    border:1px solid #0066ff; <!-- ~dark blue -->
     border-collapse:collapse;	
	}	

	.nailsizetable tr{
	background: #F2F2F2;<!-- light gray -->
	 }	
	
	.nailsizetable td{
	height: 20px;
	border-right: 1px solid #CCC;<!-- darker gray -->
    	border-left: 1px solid #CCC;
      	border-bottom: 1px solid #CCC;
	width:auto;
	 }

	.nailsizetable .headingrow td{
	border: 1px solid #0066ff;<!-- ~dark blue -->
	background: #0066ff;
	width:260px;
	font-size: 12px;
	 font-family: verdana, arial, helvetica, sans-serif; 
	 color: #FFFFFF;<!-- ~font color white -->
	 font-weight: bold;
	 text-align:center;
	 padding-left:2px; 
	 }

	.nailsizetable .firstrow td {
	 border-right: 1px solid #CCC;<!-- darker gray -->
      border-left: 1px solid #CCC;
      border-bottom: 1px solid #CCC;
	  }


	  
	 </style>
  </head>
  <body>
 
<table class="nailsizetable">
<tr>
<td class="headingrow" rowspan="2"  style="margin-top:30px; text-align:center">
Composition Shingles
</td>
<td class="rightcolumn" colspan="4">
Sheathing Thickness
</td>
</tr>
<tr>
<td class="rightcolumn">3/8"</td>
<td class="rightcolumn">1/2"</td>
<td class="rightcolumn">5/8"</td>
<td class="rightcolumn">3/4"</td>
</tr>
<tr>
<td class="leftcolumn">
3-Tab comp shingles (Bare sheathing)</td>
<td class="rightcolumn">1"</td>
<td class="rightcolumn">1"</td>
<td class="rightcolumn">1"</td>
<td class="rightcolumn">1"</td>
</tr>
<tr>
<td class="leftcolumn">
<span style="padding-left:40px">
Dimensional comp shingles (Bare sheathing)
</span>
</td>

<td class="rightcolumn">1"</td>
<td class="rightcolumn">1-1/4"</td>
<td class="rightcolumn">1-1/4"</td>
<td class="rightcolumn">1-1/4"</td>
</tr>
<tr>
<td class="leftcolumn">
3-Tab comp shingles over 3 Tab comp shingles</td>
<td class="rightcolumn">1"</td>
<td class="rightcolumn">1-1/4"</td>
<td class="rightcolumn">1-1/4"</td>
<td class="rightcolumn">1-1/4"</td>
</tr>
<tr>
<td class="leftcolumn">
Dimensional comp shingles over 3 Tab</td>
<td class="rightcolumn">1-1/4"</td>
<td class="rightcolumn">1-1/2"</td>
<td class="rightcolumn">1-1/2"</td>
<td class="rightcolumn">1-1/2"</td>
 
</tr>
</table>
  </body>
</html>

Open in new window



Not working, but correct syntax:
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="dcterms.created" content="Mon, 13 May 2013 15:47:28 GMT">
    <meta name="description" content="">
    <meta name="keywords" content="">
    <title>Table practise</title>
    
    <!--[if IE]>
    <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
	<style type= "text/css">
	    
	     .nailsizetable .rightcolumn{
	 width: 45px;
	 text-align: center !important;
	  }  
	  
	  	 .nailsizetable .leftcolumn td{
	 width: 345px;
	 text-align:center;
	 margin-left:40px;
	  } 
	  
	
	
	.nailsizetable {
	width:480px; 
    margin:auto;
    font-size:12px;
    border:1px solid #0066ff; /* ~dark blue */
     border-collapse:collapse;	
	}	

	.nailsizetable tr{
	background: #F2F2F2; /* light gray*/
	 }	
	
	.nailsizetable td{
	height: 20px;
	border-right: 1px solid #CCC; /*darker gray */
    	border-left: 1px solid #CCC;
      	border-bottom: 1px solid #CCC;
	width:auto;
	 }

	.nailsizetable .headingrow td{
	border: 1px solid #0066ff; /* ~dark blue */
	background: #0066ff;
	width:260px;
	font-size: 12px;
	 font-family: verdana, arial, helvetica, sans-serif; 
	 color: #FFFFFF; /* ~font color white */
	 font-weight: bold;
	 text-align:center;
	 padding-left:2px; 
	 }

	.nailsizetable .firstrow td {
	 border-right: 1px solid #CCC;/*darker gray */
      border-left: 1px solid #CCC;
      border-bottom: 1px solid #CCC;
	  }


	  
	 </style>
  </head>
  <body>
 
<table class="nailsizetable">
<tr>
<td class="headingrow" rowspan="2"  style="margin-top:30px; text-align:center">
Composition Shingles
</td>
<td class="rightcolumn" colspan="4">
Sheathing Thickness
</td>
</tr>
<tr>
<td class="rightcolumn">3/8"</td>
<td class="rightcolumn">1/2"</td>
<td class="rightcolumn">5/8"</td>
<td class="rightcolumn">3/4"</td>
</tr>
<tr>
<td class="leftcolumn">
3-Tab comp shingles (Bare sheathing)</td>
<td class="rightcolumn">1"</td>
<td class="rightcolumn">1"</td>
<td class="rightcolumn">1"</td>
<td class="rightcolumn">1"</td>
</tr>
<tr>
<td class="leftcolumn">
<span style="padding-left:40px">
Dimensional comp shingles (Bare sheathing)
</span>
</td>

<td class="rightcolumn">1"</td>
<td class="rightcolumn">1-1/4"</td>
<td class="rightcolumn">1-1/4"</td>
<td class="rightcolumn">1-1/4"</td>
</tr>
<tr>
<td class="leftcolumn">
3-Tab comp shingles over 3 Tab comp shingles</td>
<td class="rightcolumn">1"</td>
<td class="rightcolumn">1-1/4"</td>
<td class="rightcolumn">1-1/4"</td>
<td class="rightcolumn">1-1/4"</td>
</tr>
<tr>
<td class="leftcolumn">
Dimensional comp shingles over 3 Tab</td>
<td class="rightcolumn">1-1/4"</td>
<td class="rightcolumn">1-1/2"</td>
<td class="rightcolumn">1-1/2"</td>
<td class="rightcolumn">1-1/2"</td>
 
</tr>
</table>
  </body>
</html>

Open in new window

0
 

Author Closing Comment

by:isnoend2001
ID: 39164822
Thanks for adding that did not even think about the comment syntax
I was thinking the /* ..*/only applied to external style sheets. never really thought about it.
But now i know. Back to the drawing board
0

Featured Post

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!

Question has a verified solution.

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

Suggested Solutions

CSS3 Custom checkboxes This article shows how to style the checkbox form element using only CSS. Works in: Chrome, FF, Safari, Opera, IE9+ Uses modernizr.js to check for :checked pseudo class, falling back to plain old checkboxes (IE8 and bel…
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!
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 style different bullet points for unordered lists in CSS. Begin with a normal unordered list; the default bullet point is a solid circle: In the CSS, create a defined class of unordered list by typing "ul.S…

679 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