2 Column help please! Ahhhh!!

Discussion in 'CSS' started by MediaHustler, Mar 25, 2007.

Thread Status:
Not open for further replies.
  1. #1
    Borderless the 2 columns fit side by side perfectly but when borders are added the right sidebar goes beneath the main content box

    CSS
    #header
    {
    width: 800;
    algn:center;
    background-color: #333;
    color: #fff;
    }
    
    #content
    {
    float: left;
    width: 600px;
    background-color: #333;
    }
    
    #right
    {
    float: right;
    width: 200px;
    border-left: 3px dashed white;
    background-color: #333;
    }
    
    #container
    {
    width: 800;
    margin: 10px auto;
    background-color: #333;
    color: #fff;
    border: 3px solid white;
    }
    Code (markup):

    HTML
    <html>
    <head>
    <link rel="stylesheet" type="text/css"
    href="/style.css" />
    </head>
    <body bgcolor="black">
    
    
    <div id="container">
    <div id="header"><center><img src="/images/logocolor.jpg"></center></div>
    
    <div id="content">
    
    left
    
    </div>
    <div id="right">
    right
    
    </div>
    </div>
    </body>
    </html>
    Code (markup):
     
    MediaHustler, Mar 25, 2007 IP
  2. mcfox

    mcfox Wind Maker

    Messages:
    7,526
    Likes Received:
    716
    Best Answers:
    0
    Trophy Points:
    360
    #2
    You need to allow for the width of the borders themselves - so if you have two boxes each with a 3px border, you need to allow for the total width of the borders: 3px + 3px (both sides of one box) + 3px + 3px (both sides of second box) = 12px in total.

    Container = 800px
    Content = 600px
    Right = 200px

    Borderless, they will slip past one another but when you add the border you have a container = 800px trying to hold a total of 606px + 206px = 812px.
     
    mcfox, Mar 26, 2007 IP
  3. MediaHustler

    MediaHustler Well-Known Member

    Messages:
    1,857
    Likes Received:
    46
    Best Answers:
    0
    Trophy Points:
    120
    #3
    I got it working, thank god!

    Here's what it should look like for those who need help in the future.

    http://www.YayFreeGames.com

    HTML
    <div align="center">
    <div id="container" class="clearfix">
    <div id="header">
    
    </div>
    
    <div id="content">
    
    </div>
    <div id="right">
    
    
    </div>
    </div>
    </div>
    
    Code (markup):
    CSS
    
    #header
    {
    width: 800;
    algn:center;
    background-color: #333;
    color: #fff;
    border-bottom: 1px dashed white;
    }
    
    #content
    {
    float: left;
    width: 600px;
    padding: 2px;
    border: 0px;
    background-color: #333;
    }
    
    #right
    {
    float: right;
    width: 190px;
    padding: 2px;
    margin: 0px;
    background-color: #333;
    vertical-align:top;
    border-left: 2px dashed white;
    }
    
    #container
    {
    width: 800px;
    text-align: left;
    padding: 0px;
    margin:0 auto;
    border: 3px solid #FFF;
    background-color: #333;
    }
    
    .clearfix:after {
        content: "."; 
        display: block; 
        height: 0; 
        clear: both; 
        visibility: hidden;
    }
    
    /* Hides from IE-mac \*/
    * html .clearfix {height: 1%;}
    /* End hide from IE-mac */
    
    Code (markup):
    Thanks for the response mcfox!
     
    MediaHustler, Mar 26, 2007 IP
  4. mcfox

    mcfox Wind Maker

    Messages:
    7,526
    Likes Received:
    716
    Best Answers:
    0
    Trophy Points:
    360
    #4
    No problem. :)

    Just a thought, but you may wish to preload those images in the top navigation so they appear as soon as mouseover instead of a short delay while they download. ;)
     
    mcfox, Mar 26, 2007 IP
  5. MediaHustler

    MediaHustler Well-Known Member

    Messages:
    1,857
    Likes Received:
    46
    Best Answers:
    0
    Trophy Points:
    120
    #5
    Okay done, can you tell me if they work?
     
    MediaHustler, Mar 26, 2007 IP
  6. bacanze

    bacanze Peon

    Messages:
    2,419
    Likes Received:
    127
    Best Answers:
    0
    Trophy Points:
    0
    #6
    bacanze, Mar 26, 2007 IP
  7. MediaHustler

    MediaHustler Well-Known Member

    Messages:
    1,857
    Likes Received:
    46
    Best Answers:
    0
    Trophy Points:
    120
    #7
    Well I tried doing that but I couldn't because i'm using a javascript to complete the rollovers the buttons that show in normal html are the ones I don't need to preload. The ones I do are hidden away in javascript.

    So I used javascript for the preload. If someone visits my site for the first day please let me know if the preload thing works for the images.

    http://www.YayFreeGames.com

    Thanks!
    -Doug
     
    MediaHustler, Mar 26, 2007 IP
  8. bacanze

    bacanze Peon

    Messages:
    2,419
    Likes Received:
    127
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Yep, it was instant, good job :)

    Ash

     
    bacanze, Mar 26, 2007 IP
  9. mcfox

    mcfox Wind Maker

    Messages:
    7,526
    Likes Received:
    716
    Best Answers:
    0
    Trophy Points:
    360
    #9
    For some reason I'm not seeing an efficient preload of those images - dunno why - I can see the code in the source.

    You still have errors in your css - don't forget you need to also allow for the padding in the same way you need to allow for the borders ;) I'm seeing the same problem as you had initially when I view the site in Firefox - that's down to the padding.

    I've highlighted the errors.

    #header
    {
    width: 800[B]px[/B];
    [I][B]align[/B]:center;[/I] (sp)
    background-color: #333;
    color: #fff;
    border-bottom: 1px dashed white;
    }
    
    #content
    {
    float: left;
    width: 600px;
    padding: 5px;  [B]<<<-- must allow for the padding[/B]
    border: 0px;
    background-color: #333;
    }
    
    #right
    {
    float: right;
    width: 190px;
    padding: 2px; [B]<<<-- must allow for the padding[/B]
    margin: 0px;
    background-color: #333;
    vertical-align:top;
    border-left: 2px dashed white;
    }
    Code (markup):
     
    mcfox, Mar 26, 2007 IP
  10. MediaHustler

    MediaHustler Well-Known Member

    Messages:
    1,857
    Likes Received:
    46
    Best Answers:
    0
    Trophy Points:
    120
    #10
    Bad timing, seems like you loaded the site just as I was editing it hehe. Look now.
     
    MediaHustler, Mar 26, 2007 IP
  11. mcfox

    mcfox Wind Maker

    Messages:
    7,526
    Likes Received:
    716
    Best Answers:
    0
    Trophy Points:
    360
    #11
    Yep, the preload works fine now. :)
     
    mcfox, Mar 26, 2007 IP
    Jat likes this.
Thread Status:
Not open for further replies.