Results 1 to 4 of 4

Thread: Placing Two tables side by side with CSS

  1. #1
    Join Date
    Jul 2011
    Posts
    58
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Exclamation Placing Two tables side by side with CSS

    I want to place two tables side-by-side in the same row with CSS but I can't.
    What is wrong with the below code?
    Code:
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>
    <style type="text/css">
    div #tablecontainer
    {
    postion:relative;}
    
    #t1
    { 
    width:500px;
    height:200px;
     border:3px solid black ;
        }  
    
     <!-- 2nd table in row styles -->
     
     #t2
    { 
     left:600px;
      width:500px;
    height:200px;
     border:3px solid black ;
       }  
    
    </style>
    
    </head>
    
    <body>
    <div id="tablecontainer">
        <!-- Table 1 markup-->
        <table  id="t1">
          <tr>
             <td>1</td>
    		  <td>1</td>
          </tr>
    	  
       <tr>
           <td>1</td>
    	    <td>1</td>
          </tr>
      </table>
    	
        <!-- Table 2 markup-->
    <table id="t2"> 
     <tr>  
                       <td>1</td>
          			  <td>1</td>			 
      </tr> 
      <tr>
    	    <td>1</td>
    		<td>1</td>
    	</tr>					 
    </table>  
    </div>
    </body>
    </html>
    Actually I want to create the following layout shown in the attached picture.
    I tried for the last 5 hours till my eyes are now burning. I have failed!!
    How to do that?
    Seniors Please Help me.
    Thanks
    Last edited by dcr33; 07-15-2011 at 05:21 AM. Reason: modify

  2. #2
    Join Date
    May 2011
    Location
    SFBA, CA, USA
    Posts
    94
    Thanks
    6
    Thanked 7 Times in 7 Posts

    Default

    Try this:
    Code:
    <style type="text/css">
    div #tablecontainer
    {
    postion:relative;}
    
    #t1, #t2 {
    width:500px;
    height:200px;
    border:3px solid black ;
    }
    #t1
    { 
    float:left;
        }  
    
     <!-- 2nd table in row styles -->
     
     #t2
    { 
    float:right   }  
    
    </style>
    dbc

  3. #3
    Join Date
    Jul 2011
    Posts
    58
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Cool

    Hi deathbyceese
    Thanks .But that isn't the code that gives the picture in the figure!!
    Also note that float cannot be used since there is maximum gap of say, 5px between the tables.

  4. #4
    Join Date
    Jul 2011
    Location
    Denmark
    Posts
    18
    Thanks
    1
    Thanked 4 Times in 4 Posts

    Default

    Hey, hope this'll work, tho it might not be the right dimension I used for each table:

    Code:
    <style>
    #wrap {
    	width: 340px;
    }
    
    #wrap table {
    	display: block;
    	float: left;
    	width: 150px;
    	border: 1px solid #000;
    	border-bottom: 0;
    	margin: 5px;
    }
    
    #wrap table td {
    	border-bottom: 1px solid #333;
    	width: 150px;
    }
    </style>
    
    <div id="wrap">
    <table border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
    </table>
    
    <table border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
    </table>
    
    <table border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
    </table>
    
    <table border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
    </table>
    </div>
    Should look like:


    Regards Toby

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •