Results 1 to 2 of 2

Thread: Just starting with CSS

  1. #1
    Join Date
    May 2007
    Posts
    31
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Default Just starting with CSS

    I'm trying to fit 3 columns under a top section and I can get the left-side and centre to nest together but the right-side is beneath the centre column. I know someone who knows what they're doing will spot why.

    This is my CSS

    #header {
    height: 120px;
    background-color:#0033FF
    }

    #leftcol {
    width: 210px;
    float: left;
    background-color:#00CCFF
    }

    #centrecol {
    width: 570px;
    margin-left: 210px;
    background-color:#00CCCC
    }

    #rightcol {
    width: 190px;
    float: right;
    background-color:#00CCFF
    }


    and this is my HTML

    <body>
    <div id="header">This is the header area</div>
    <div id="leftcol">This is the left column</div>
    <div id="centrecol">This is the centre column</div>
    <div id="rightcol">This is the right column</div>
    </body>

    Please... what changes need to be made to make the right-side level with the other two columns?

  2. #2
    Join Date
    Jan 2007
    Posts
    629
    Thanks
    10
    Thanked 28 Times in 28 Posts

    Default

    Your centercol needs to float left as well, and sometimes you need to make the width of the columns 1px smaller then the window, just in case. I think the problem here is that the center column needs to float left. I would also have the right column float left, if possible.

    EDIT: You had another problem.
    Code:
    #centrecol {
    width: 570px;
    /*needs to float left*/
    margin-left: 210px;   /*What is that for? It is blocking the right column*/
    background-color:#00CCCC
    }
    
    #rightcol {
    width: 190px;
    float: right; /*I could make that float left instead*/
    background-color:#00CCFF
    }
    Here is the solution:
    Code:
    #header {
    height: 120px;
    background-color:#0033FF
    }
    
    #leftcol {
    width: 210px;
    float: left;
    background-color:#00CCFF
    }
    
    #centrecol {
    width: 570px;
    float:left;
    background-color:#00CCCC
    }
    
    #rightcol {
    width: 190px;
    float: left;
    background-color:#00CCFF
    }
    It seems to work
    Last edited by Jas; 02-14-2008 at 07:26 PM.
    --Jas
    function GreatMinds(){ return "Think Like Jas"; }
    I'm gone for a while, but in the meantime: Try using my FTP script | Fight Bot Form Submissions

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
  •