Go Back   SitePoint Forums > Forum Index > Design Your Site > Web Page Design > CSS
Newsletter FAQ Members List Calendar Mark Forums Read

New to SitePoint Forums? Register here for free!

SitePoint Sponsor
 
Reply
 
Thread Tools Display Modes
Old Oct 14, 2006, 20:18   #1
njrocket
SitePoint Enthusiast
 
Join Date: Aug 2006
Posts: 74
setting up tables

Hi guys, i want to set up vertical tables that are next to each other. I want to be able to do this basically.


I want to be able to have another set of tables that different, underneath theses. So lets say 3 tables on top, and 3 underneath them. How can i code this?
njrocket is offline   Reply With Quote
Old Oct 14, 2006, 20:21   #2
Tyssen
SitePoint Wizard
bronze trophy
 
Tyssen's Avatar
 
Join Date: Oct 2005
Location: Brisbane, QLD
Posts: 4,024
You'll need to float the tables left and give them a width. Work out the widths and margins so that you get the number of tables you want on each line.
Tyssen is offline   Reply With Quote
Old Oct 14, 2006, 20:39   #3
njrocket
SitePoint Enthusiast
 
Join Date: Aug 2006
Posts: 74
Quote:
Originally Posted by Tyssen
You'll need to float the tables left and give them a width. Work out the widths and margins so that you get the number of tables you want on each line.
Can somebody give me a sample script, so i can just fool around with the widths and color later on? I need a basic layout first.
njrocket is offline   Reply With Quote
Old Oct 14, 2006, 20:48   #4
Tyssen
SitePoint Wizard
bronze trophy
 
Tyssen's Avatar
 
Join Date: Oct 2005
Location: Brisbane, QLD
Posts: 4,024
Code:
 .verticalTable { float: left; margin-right: 1em; }
 #table1 { width: 100px; }
 #table2 { width: 120px; }
 #table3 { width: 130px; }
 #table4 { width: 105px; }
 
 <table id="table1" class="verticalTable"></table>
 <table id="table2" class="verticalTable"></table>
 <table id="table3" class="verticalTable"></table>
 <table id="table4" class="verticalTable"></table>
Or if you wanted some tables to have the same width, make the IDs classes instead, e.g:

Code:
  .verticalTable { float: left; margin-right: 1em; }
 .table1 { width: 100px; }
  .table2 { width: 120px; }
 
  <table class="verticalTable table1"></table>
  <table class="verticalTable table2"></table>
  <table class="verticalTable table1"></table>
  <table class="verticalTable table2"></table>
Tyssen is offline   Reply With Quote
Old Oct 15, 2006, 10:18   #5
njrocket
SitePoint Enthusiast
 
Join Date: Aug 2006
Posts: 74
its not working how i want it to be. The way you have it set up, its table on top of each other. I want 3 seperate vertical tables going across. Than another set of 3 tables underneath them.
Example of how i want it set up.

Last edited by njrocket; Oct 15, 2006 at 12:33.
njrocket is offline   Reply With Quote
Old Oct 15, 2006, 15:07   #6
Paul O'B
CSS Advisor
silver trophybronze trophy
SitePoint Award Recipient
 
Paul O'B's Avatar
 
Join Date: Jan 2003
Location: Hampshire UK
Posts: 27,436
Hi,

Tyssens code will do that if you copy it correctly

Heres a more advanced example but you will need to fix the width of the container if you don't want the tables to wrap when the screen is resized.

Code:
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
 <title>Untitled Document</title>
 <style type="text/css">
 * {margin:0;padding:0}
 ul.vertical-table{list-style:none;}
 ul.vertical-table li{clear:both;padding:1em 0;border-bottom:1px solid red}
 .vertical-table table{ 
 	float: left; 
 	margin:0 1em;
 	background:#ffcccc;
 	border:1px solid #000;
 	dislay:inline;/* ie dbl margin bug*/
 }
  .table1 { width: 100px; }
  .table2 { width: 120px; }
  .table3 { width: 130px; }
 	
 	/* clear floats without structural mark-up - do not alter */
 	.clearfix:after {
 	content:"."; 
 	display:block; 
 	height:0; 
 	clear:both; 
 	visibility:hidden;
 }
 .clearfix {
 	display:inline-block;
 }
 
  /* mac hide \*/
 	* html .clearfix {height: 1%;}
 	  .clearfix {display: block;}
  /* End hide */
 
 
 </style>
 </head>
 <body>
 <ul class="vertical-table">
 	<li class="clearfix">
 		<table class="table1">
 			<tr>
 				<td>Table1</td>
 			</tr>
 		</table>
 		<table class="table2">
 			<tr>
 				<td>Table2</td>
 			</tr>
 		</table>
 		<table class="table3">
 			<tr>
 				<td>Table3</td>
 			</tr>
 		</table>
 	</li>
 	<li class="clearfix">
 		<table class="table1">
 			<tr>
 				<td>Table1</td>
 			</tr>
 		</table>
 		<table class="table2">
 			<tr>
 				<td>Table2</td>
 			</tr>
 		</table>
 		<table class="table3">
 			<tr>
 				<td>Table3</td>
 			</tr>
 		</table>
 	</li>
 </ul>
 </body>
 </html>
Hope it helps.
Paul O'B is online now   Reply With Quote
Old Oct 15, 2006, 15:38   #7
njrocket
SitePoint Enthusiast
 
Join Date: Aug 2006
Posts: 74
alright thanks for the help, im going to try the code and see if it works out for me this time. How am i doing the code wrong from the top. I copied and pasted the first half into css, and the other half into my html coding, and its forming one table. Are you sure that code is fully correct? Any idea what im doing, because id rather have a simple script for it, and then just modify it as i go along. I'l fool around with the widths, but id rather set it up first, thanks
njrocket is offline   Reply With Quote
Old Oct 15, 2006, 15:59   #8
Tyssen
SitePoint Wizard
bronze trophy
 
Tyssen's Avatar
 
Join Date: Oct 2005
Location: Brisbane, QLD
Posts: 4,024
Quote:
Originally Posted by njrocket
Any idea what im doing
Not without you showing us your actual code or a link to the page.
Tyssen is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread | Next Thread »

Thread Tools
Display Modes

 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Sponsored Links
 
Forum Jump


All times are GMT -7. The time now is 16:15.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright 1998-2009, SitePoint Pty Ltd. All Rights Reserved