Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Feb 2012
    Posts
    13
    Thanks
    4
    Thanked 0 Times in 0 Posts

    CSS Div Help - Making 3 columns by 3 rows layout



    Hi all.

    I am trying to recreate this website.
    I have made a div called container that contains everything.

    After I have made each div for the header and first 3 columns I am having problems getting the next 3 columns to align underneath.

    I found that I had to create a second container for each new column.
    I am not sure if that is right or wrong, or if there is an easier way?

    I am also finding myself using negative margins alot to align columns or banner divs perfectly.
    I have a feeling this is wrong too?

    Code:
    <body>
    
    <div id="wrap">
    	<div id="header">
    		<ul>
    			<li id="navhead"><a href="#">Home</a> |</li>
    			<li id="navhead"><a href="#">My Account</a> |</li>
    			<li id="navhead"><a href="#">Rakeback</a> |</li>
    			<li id="navhead"><a href="#">Promotions</a> |</li>
    			<li id="navhead"><a href="#">Coaching</a> |</li>
    			<li id="navhead"><a href="#">Refer-A-Friend</a> |</li>
    			<li id="navhead"><a href="#">FAQ</a> |</li>
    			<li id="navhead"><a href="#">Support</a></li>
    		</ul>
    	</div> <!-- end header -->
    
    <div id="banner">	
    
    </div> <!-- end banner -->
    
    
    <div id="navigation">
    		<ul>
    			<li id="navmain"><a href="#">Ongame</a></li>
    			<li id="navmain"><a href="#">Party</a></li>
    			<li id="navmain"><a href="#">Microgaming</a></li>
    			<li id="navmain"><a href="#">IPoker</a></li>
    			<li id="navmain"><a href="#">Entraction</a></li>
    			<li id="navmain"><a href="#">Cake</a></li>
    			<li id="navmain"><a href="#">Independant</a></li>
    		</ul>
    </div> <!-- end navigation -->
    
    
    <div id="column1">
    	<h2>Rakeback</h2>
    		<div id=rakebackbox>
    		</div>
    </div> <!-- end loginbox -->
    
    
    <div id="column2">
    	<div class="mainpic">
    		<img src="img/pkr.png" alt="pkr" width="540px" height="295px"/>
    	</div> <!-- end mainpic -->
    </div> <!-- end main -->
    
    
    <div id="column3">
    	<h2>Offers</h2>
    	<div id="offersbox">
    	</div>
    </div> <!-- end offers -->
    	
    
    </div> <!-- end wrap -->
    
    	
    <div id=wrap2>
    	
    	<div id="column4">
    	<h2>Latest News</h2>
    	<div id=newsbox>
    	</div>
    </div> <!-- end news -->
    
    
    <div id="column5">
    	<h2>Free Poker Coaching</h2>
    	<div id=main2box>
    	</div>
    </div> <!-- end main2 -->
    
    <div id="column6">
    	<h2>Rakeback Calculator</h2>
    </div> <!-- end calculator -->

    Code:
    ol, ul { 
    		list-style: none;
    	}
    	
    	
    	
    	h2 { font-size: 16px; }
    		
    		
    	a { text-decoration: none;
    		color: white; }
    		
    
    body {background:#CCCCCC;
    margin-top:-16px;
    padding-top:0px;
    
    }		
    		
    #wrap {
    	width: 960px;
    	margin: auto;
    	height:395px;
    
    		background: white;	
    		}
    		
    #header {
    	background-color: black; 
    	height: 35px;
    	margin-bottom:0px;}
    	
    #header ul {
    	padding-left: 15px;
    	margin-bottom:0px;
    	}
    	
    #header li {
    	float: left; 
    	padding-left: 6px;
    	color: white;
    	font-size: 15px;
    	margin-top:10px;
    	margin-bottom:0px;
    	
    }
    
    #banner 
    	{ background-image:url(img/banner.jpg);
    	 height:100px;
      width:960px;
      margin-bottom:0px;
      margin: 0 0 0 0;
     	}
    	
    	
    #navigation
    	{background-color: black;
    	height:30px;
    	margin-top:-16px;
    
    	}
    	
    #navigation ul {
    
    	padding-left: 30px;
    	}
    	
    #navigation li {
    	float:left;
    	font-family:arial;
    	margin-left:50px;
    	color: white;
    	font-size: 18px;
    	margin-top:5px;}
    	
    
    	
    /* HEADINGS */
    
    #column1 {
      background:transparent url(img/heading.png) no-repeat scroll 0 0;
      height:25px;
      text-align:center;
      line-height:1px;
      width:187px;
      color:white;
      font-size:14px;
      margin-left:10px;
      margin-top:15px;
      margin-bottom:0px;
      float:left
       }
       
       
      #rakebackbox {
      background-color:black;
      margin-top:0px;
      height:295px;
      text-align:center;
      width:187px;
      color:white;
      font-size:14px;
     
         }
    	
    	
    #column2 {
    
    margin-left:15px;
    
    margin-top:20px;
    float:left;
    }
    
    #column3 {
      background:transparent url(img/heading.png) no-repeat scroll 0 0;
      height:25px;
      text-align:center;
      line-height:1px;
      width:187px;
      color:white;
      font-size:14px;
      margin-right:10px;
      margin-top:15px;
      margin-bottom:0px;
      float:right
       }
       
       
      #offersbox {
      background-color:black;
      margin-top:0px;
      height:295px;
      text-align:center;
      width:187px;
      color:white;
      font-size:14px;
     
         }
    	 
    
    
    #wrap2 {
    	width: 960px;
    	margin: auto;
    	height:1000px;
    	margin-top:-13px;
    		background: white;	
    			}
    
    		
    #column4  {
      background:transparent url(img/heading.png) no-repeat scroll 0 0;
      height:25px;
      text-align:center;
      line-height:2px;
      width:187px;
      color:white;
      font-size:14px;
      margin-left:10px;
      margin-top:150px;
      margin-bottom:0px;
      float:left
       }
       
       
      #newsbox {
      background-color:black;
      margin-top:-1px;
      height:175px;
      text-align:center;
      width:187px;
      color:white;
      font-size:14px;
     
         }
    	 
    #column5 {
    
    margin-left:15px;
    width:543px;
    text-align:center;
    line-height:2px;
    background-color:black;
    float:right;
    height:25px;
    color:white;
    margin-top:15px;
    float:left;
    
    }
    
    
    #main2box {
    
    margin-left:0px;
    width:543px;
    background-color:black;
    height:175px;
    
    }
    	
    .headertab { 
     background:transparent url(img/heading.png) no-repeat scroll 0 0;
     }

  • #2
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,688
    Thanks
    22
    Thanked 1,829 Times in 1,813 Posts
    Hello rubbed,
    Maybe a different approach would make it easier. Look how re-using classes can lighten up your CSS -
    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=utf-8" />
    <title>Untitled Document</title>
    <style type="text/css">
    html, body {
    	margin: 0;
    	background: #fc6;
    }
    #container {
    	width: 800px;
    	margin: 30px auto;
    	padding: 0 10px 100px;
    	overflow: auto;
    	background: #999;
    }
    .wrap {
    	margin: 10px 0;
    	padding: 10px;
    	overflow: auto;
    	background: #ccc;
    }
    .column1,
    .column3 {
    	height: 200px;
    	width: 150px;
    	background: #000;
    }
    .column1 {float: left;}
    .column3 {float: right;}
    .column2 {
    	height: 200px;
    	width: 450px;
    	margin: 0 auto;
    	background: #000;
    }
    </style>
    </head>
    <body>
        <div id="container">
        	<div class="wrap">
            	<div class="column1">
                <!--end .column1--></div>
            	<div class="column3">
                <!--end .column3--></div>
            	<div class="column2">
                <!--end .column2--></div>
            <!--end .wrap--></div>
        	<div class="wrap">
            	<div class="column1">
                <!--end .column1--></div>
            	<div class="column3">
                <!--end .column3--></div>
            	<div class="column2">
                <!--end .column2--></div>
            <!--end .wrap--></div>
        	<div class="wrap">
            	<div class="column1">
                <!--end .column1--></div>
            	<div class="column3">
                <!--end .column3--></div>
            	<div class="column2">
                <!--end .column2--></div>
            <!--end .wrap--></div>
        <!--end container--></div>
    </body>
    </html>
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad

  • Users who have thanked Excavator for this post:

    rubbed (02-11-2012)

  • #3
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,594
    Thanks
    23
    Thanked 646 Times in 645 Posts
    After looking at what Excavator did, mine looks puny, but here is my attempt to use what rubbed was doing. I commented out what was not needed and my additions are not indented. All changes to the css section.
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    	<title>New document</title>
    	<meta name="generator" content="TSW WebCoder 2010" />
    
    <style type="text/css">
    #wrap
    {
    border: purple solid 1px;
    	width: 960px;
    	height:525px;
    	margin: auto;
    	background: white;
    }
    
    #header
    {
    	background-color: black;
    	height: 35px;
    	//margin-bottom:0px;
    }
    
    #banner
    {
    	background-color: red;   // url(img/banner.jpg);
    	height:100px;
    	//width:900px;
    	//margin-bottom:0px;
    	//margin: 0 0 0 0;
    }
    
    
    #navigation
    {
    	background-color: black;
    	height:30px;
    	//margin-top:-16px;
    }
    
    /* HEADINGS */
    
    #column1 {
      //background:transparent url(img/heading.png) no-repeat scroll 0 0;
    border: red solid 1px;
    background-color:black;
      color:white;
      height:25px;
      width:187px;
      text-align:center;
      line-height:1px;
      font-size:14px;
      margin-left:10px;
      margin-top:15px;
      //margin-bottom:0px;
      float:left
       }
    
      #rakebackbox
    {
    border: green solid 1px;
    	//background-color:black;
    	//margin-top:0px;
    	height:295px;
    	text-align:center;
    	width:187px;
    	color:white;
    	font-size:14px;
    }
    
    #column2
    {
    border: red solid 1px;
    width: 540px;
    height: 295px;
    	margin-left:15px;
    	margin-top:20px;
    	float:left;
    }
    
    #column3
    {
    border: red solid 1px;
    	//background:transparent url(img/heading.png) no-repeat scroll 0 0;
    	height:25px;
    	text-align:center;
    	line-height:1px;
    	width:187px;
    background-color:black;
    	color:white;
    	font-size:14px;
    	margin-right:10px;
    	margin-top:15px;
    	//margin-bottom:0px;
    	float: right;
    }
    
    #offersbox
    {
    border: green solid 1px;
    	//background-color:black;
    	color:white;
    	//margin-top:0px;
    	height:295px;
    	width:187px;
    	text-align:center;
    	font-size:14px;
    }
    
    
    
    #wrap2
    {
    border: blue solid 1px;
    	width: 960px;
    	margin: auto;
    	height:230px;
    	margin-top:13px;
    	background: white;
    }
    
    #column4
    {
      //background:transparent url(img/heading.png) no-repeat scroll 0 0;
    background-color:black;
      color:white;
      height:25px;
      width:187px;
      text-align:center;
      line-height:2px;
      font-size:14px;
      margin-left:10px;
      //margin-top:150px;
      //margin-bottom:0px;
      float: left;
    }
    
    
    #newsbox
    {
    border: blue solid 1px;
    	//background-color:black;
    	color:white;
    	margin-top:-1px;
    	height:175px;
    	width:187px;
    	text-align:center;
    	font-size:14px;
    }
    
    #column5
    {
    	background-color:black;
    	color:white;
    	width:510px;
    	height:25px;
    	text-align:center;
    	line-height:2px;
    	//margin-top:15px;
    	margin-left: 10px;
    float:left;
    }
    
    #main2box
    {
    	//width:543px;
    	height:175px;
    	background-color:red;
    	margin-left:0px;
    }
    
    
    #column6
    {
    border: blue solid 1px;
    	//background:transparent url(img/heading.png) no-repeat scroll 0 0;
    background-color:black;
    	color:white;
    	height:25px;
    	width: 220px;              // 187px;  done so "Rakeback Calculator" would fit
    	text-align:center;
    	line-height:1px;
    	font-size:14px;
    	margin-right:10px;
    	//margin-top:15px;
    	//margin-bottom:0px;
    	float: right;
    }
    </style>
    
    </head>
    
    <body>
    
    <div id="wrap">
    	<div id="header">
    	</div> <!-- end header -->
    
    	<div id="banner">
    	</div> <!-- end banner -->
    
    
    	<div id="navigation">
    	</div> <!-- end navigation -->
    
    
    	<div id="column1">
    		<h2>Rakeback</h2>
    			<div id="rakebackbox">
    			</div>
    	</div> <!-- end loginbox -->
    
    
    	<div id="column2">
    		<div class="mainpic">
    			<img src="img/pkr.png" alt="pkr" width="540px" height="295px"/>
    		</div> <!-- end mainpic -->
    	</div> <!-- end main -->
    
    
    	<div id="column3">
    		<h2>Offers</h2>
    		<div id="offersbox">
    		</div>
    	</div> <!-- end offers -->
    
    
    </div> <!-- end wrap -->
    
    
    <div id="wrap2">
    
    	<div id="column4">
    	<h2>Latest News</h2>
    	<div id="newsbox">
    	</div>
    	</div> <!-- end news -->
    
    
    	<div id="column5">
    		<h2>Free Poker Coaching</h2>
    		<div id="main2box">
    		</div>
    	</div> <!-- end main2 -->
    
    	<div id="column6">
    		<h2>Rakeback Calculator</h2>
    	</div><!-- end calculator -->
    </div> <!--  end wrap2  -->
    </body>
    </html>

  • Users who have thanked sunfighter for this post:

    rubbed (02-11-2012)

  • #4
    New Coder
    Join Date
    Feb 2012
    Posts
    13
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Thanks for the extremely helpful replys, I learned alot from that and only wish I had of checked back here earlier.. have had my head stuck in this web design project and didn't realize where the time went.

    Since my last post I have designed this:
    http://nipoker.com/test/index.html

    The css is probably a mess as it's the second website I have ever made so it might be complicated to look through but I am having some big problems.

    Basically the site looks fine for me in IE/Chrome but in firefox the margins look off and there is no gaps between some of the columns.

    For the 3 boxes:
    What is rakeback
    Refer a friend
    About

    I had inserted 1px gaps between each of the boxes, but for some people and on firefox it looks like it is one big box, as there is no gap and they look adjoined.

    I inserted these 3 columns in a new wrap
    Code:
    #wrap3 { /* Wrap 3 contains next 3 columns: 'latest news' 'free coaching' and 'calculator' */
    width: 960px;
    margin: auto;
    height:195px;
    margin-top:0px;
    background: white;		
    }

    Here is the columns code
    Code:
    /* WRAP 3 Column Headers followed by Column body */
    
    
    #whatisrb {
    background-color:black;
    height:185px;
     width:319px;
    text-align:center;
      line-height:20px;
       color:white;
      font-size:14px;
      margin-right:0px;
     margin-top:10px;
      margin-bottom:0px;
      float:left;
      position:relative;
       }
       	 
    	 
    #refer {
    background-color:black;
    height:185px;
    width:320px;
    text-align:center;
    line-height:20px;
    color:white;
    font-size:14px;
    margin-left:2px;
    margin-top:10px;
    margin-bottom:0px;
    float:left;
         }
       	 
    	
    #about {
    background-color:black;
    height:185px;
    width:318px;
    text-align:center;
    line-height:20px;
    color:white;
    font-size:14px;
    margin-left:0px;
    margin-top:10px;
    margin-bottom:0px;
    float:right;
    }

    And the HTML

    Code:
    <div id="wrap3"> <!-- start wrap3 -->
    
    
    <div id="whatisrb">
    	<h3> <span class="white"> What is </span>Rakeback?</h3>
    	</div> <!-- end whatisrb -->
    
    <div id="refer">
    	<h3> <span class="white">Refer</span>-A-<span class="white">Friend</span></h3>
    </div> <!-- end refer -->
    
    <div id="about">
    	<h3> About <span class="white">PokerPeice</span></h3>
    </div> <!-- end about -->
    
    </div> <!-- end wrap3 -->
    It might be easier to save the files on the link I posted above if anyone can help.

    Also have the same problem for the navigation headers, should be a 1px break below the "Rakeback" and "latest news" headings.

  • #5
    New Coder
    Join Date
    Feb 2012
    Posts
    13
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Anyone? still stuck

  • #6
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,594
    Thanks
    23
    Thanked 646 Times in 645 Posts
    Removed margin-bottom's, removed position:relative(try to stay away from these) made widths all 319px and added the 1px margins to the middle box:
    Code:
    #wrap3
    {
    	background: white;
    	width: 960px;
    	height:195px;
    	margin-left: auto;
    	margin-right: auto;
    }
    
    #whatisrb
    {
    	background-color:black;
    	color:white;
    	height:185px;
    	width:319px;
    	text-align:center;
    	line-height:20px;
    	font-size:14px;
    	margin-right:0px;
    	margin-top:10px;
    	float:left;
    }
    
    #refer
    {
    	background-color:black;
    	color:white;
    	height:185px;
    	width:319px;
    	text-align:center;
    	line-height:20px;
    	font-size:14px;
    	margin-left:1px;
    	margin-right:1px;
    	margin-top:10px;
    	float:left;
    	}
    
    
    #about
    {
    	background-color:black;
    	color:white;
    	height:185px;
    	width:319px;
    	text-align:center;
    	line-height:20px;
    	font-size:14px;
    	//margin-left:0px;
    	margin-top:10px;
    	float:left;
    }
    Last edited by sunfighter; 02-11-2012 at 12:07 AM.

  • Users who have thanked sunfighter for this post:

    rubbed (02-11-2012)

  • #7
    New Coder
    Join Date
    Feb 2012
    Posts
    13
    Thanks
    4
    Thanked 0 Times in 0 Posts
    thank you very much! been trying to figure that out for hours...

    also have a similar problem with my navigation menu.

    My headers "Rakeback" "Offers" "Latest News" etc are supposed to have 1px gap underneath them and the column under it, like a seperator.
    It shows this 1px gap in chrome but not in firefox/IE.

    Here is the code:

    Code:
    #wrap 
    { /* Wrap 1 containing navigation banners and first 3 columns */
    	width: 960px;
    	margin: auto;
    	height:482px;
    	background: white;	
    
    			}
    
    
    #rakeback {  /* rounded header box */
      background:transparent url(img/heading.png) no-repeat scroll 0 0;
      height:25px;
      text-align:center;
      line-height:20px;
      width:187px;
      color:white;
      font-size:14px;
      margin-left:10px;
      margin-top:20px;
      margin-bottom:0px;
      float:left;
      
      
       }
       
       
      #rakebackbox { /* content box below header */
      background-color:black;
      margin-top:6px;
      height:275px;
      text-align:center;
      width:187px;
      color:white;
      font-size:14px;
    
    
    div id="rakeback">
    	<h2>Rakeback</h2>
    		<div id="rakebackbox">
    		</div>
    </div> <!-- end loginbox -->
    Would really appreciate it if you could figure this one out


  •  

    Posting Permissions

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