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 8 of 8
  1. #1
    New to the CF scene
    Join Date
    Apr 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation divs not lining up; div height double what it should be

    Hi,

    I'm having a bit of trouble making a three-columned div layout. The middle column ("content") and the right column are rendering correctly in both FF and IE.

    However, in IE, you'll notice that there is a slight 2px or so "space" between the left div and the "content" div. Can you tell my why this is, and how it can be corrected?

    Also, The columns themselves are expended to the full height of the browser, however there is a space underneath them that continues for another 100% height or so. I also don't know why this is.

    The website can be seen here: http://www.epalsconnect.com/clinic/index.html
    CSS file here: http://www.epalsconnect.com/clinic/styles/style.css

    Any help would be greatly appreciated. Thanks,

    Garrett

    HTML:
    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">
    <head>
    <title>#PAGENAME#</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <link rel="stylesheet" type="text/css" href="./styles/style.css" />
    </head>
    
    <body>
    <div id="wrapper">
      <div id="left"></div>
      <div id="content">CONTENT</div>
      <div id="right"></div>
    </div>
    </body>
    </html>
    CSS:
    Code:
    body, html { 
      width: 100%;
      height: 100%;
      margin: 0px;
    }
    
    body {
      font-family: Arial, Helvetica, sans-serif;
      background-color: #3e97f3;
    }
    
    #wrapper {
      text-align: left;
      margin: 0px auto;
      width: 100%;
      height: 100%;
      background: url("/path/to/your/background_cols.gif") repeat;
    }
    
    #left {
      float: left;
      width: 200px;
      height: 100%;
      background: url('../images/leftBg.jpg') right repeat-y;
    }
    
    #right {
      position: relative;
      top: 0;
      right: 0;
      width: 200px;
      height: 100%;
      background: url('../images/rightBg.jpg') left repeat-y;
    }
    
    #content { 
      border-left: 1px solid #000000;
      border-right: 1px solid #000000;
      margin-right: 200px;
      margin-left: 200px;
      height: 100%;
      background: #ffffff url('../images/contentBg.gif') bottom right no-repeat;
    }

  • #2
    Regular Coder
    Join Date
    Nov 2006
    Posts
    247
    Thanks
    13
    Thanked 26 Times in 24 Posts
    Well, the reason it's expanding another 100&#37; is because you right column is being forced under the left column. The reason for this is your borders on the content div. Borders, paddings, and margins aren't counted towards to width of a div. So basically what you're getting is a total of 100% PLUS 2 pixels width. The result is the third column being forced down to the next row. Taking out the border will fix it. Mixing percents and pixels to form the width is always going to lead to problems like this. Also, just fair warning, when you have a height in percent, and the content expands beyond the height of the browser, the div will not span, and the content will just overflow it.
    Last edited by Majoracle; 12-21-2007 at 03:34 AM.

  • #3
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,675
    Thanks
    22
    Thanked 1,827 Times in 1,811 Posts
    Hello GarrettVD,
    Get your columns in order with this (I hope... didn't look at it in IE)
    CSS
    Code:
    body, html { 
      width: 100%;
      height: 100%;
      font-family: Arial, Helvetica, sans-serif;
      text-align: left;
      background: #3e97f3 url("http://www.epalsconnect.com/clinic/images/background_cols.gif");
    
    }
    * {
    margin: 0;
    padding: 0;
    border: none;
    }
    
    
    #left {
      float: left;
      width: 200px;
    height: 300px;
      background: url('http://www.epalsconnect.com/clinic/images/leftBg.jpg')right repeat-y;
    }
    
    #right {
      width: 200px;
    height: 300px;
    float: right;
      background: url('http://www.epalsconnect.com/clinic/images/rightBg.jpg') left repeat-y;
    }
    
    #content { 
    height: 300px;
    margin: 0 200px;
      border-left: 1px solid #000000;
      border-right: 1px solid #000000;
      background: #ffffff url('http://www.epalsconnect.com/clinic/images/contentBg.gif') bottom right no-repeat;
    }
    and re-order your markup like this:
    Code:
      <div id="left"></div>
      <div id="right"></div>
      <div id="content">CONTENT</div>
    You may need to play with the margins on #content if the borders make a float drop.

    For a full height solution that doesn't break when you put text in it, have alook at my example.
    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

  • #4
    New to the CF scene
    Join Date
    Apr 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks, guys! I appreciate the help!

    @ Majoracle: I understand what you mean about taking into account the margins, borders, and paddings. But it renders beautifully in FF -- The left and right cols are nice and snug up against the content col. But in IE it's showing an extra 2 or so pixels on each side... Can you tell me why this is, given my CSS / HTML code below? Thanks a lot!



    @ Excavator: Awesome, thanks for the link! I checked it out and I tweaked my HTML / CSS slightly, so that the text in the content column doesn't "spill out" when the 100&#37; height of the browser screen has been surpassed.

    However, if you take a look at my website, the left and right columns are not extending to the same length as that of the Content column. Setting the height: 100% will only ensure that the first 100% is filled with background image, but what about the rest? Is there a way to fix this?

    Thanks again, guys!

    http://www.epalsconnect.com/clinic/index.html <- Website
    http://www.epalsconnect.com/clinic/styles/style.css <- Style

    HTML:
    Code:
    <body>
    <div id="wrap">
      <div id="left">aaa</div>
      <div id="right">bbb</div>
      <div id="content"><p>CONTENT CONTENT CONTENT CONTENT CONTENT [etc...]</p></div>
    </div>
    </body>
    CSS:
    Code:
    body { 
      height: 100%;
      font-family: Arial, Helvetica, sans-serif;
      text-align: left;
      background: #3e97f3 url("http://www.epalsconnect.com/clinic/images/background_cols.gif");
    }
    
    html {
      height: 100%;
    }
    
    * {
    margin: 0;
    padding: 0;
    border: none;
    }
    
    #wrap {
      width: 1000px;
      margin: 0 auto;
      text-align: left;
      min-height: 100%; 
    }
    
    
    * html #wrap {
    	height: 100%
    }
    
    #left {
      float: left;
      width: 100px;
      background: #3e97f3 url('http://www.epalsconnect.com/clinic/images/leftBg.jpg') right repeat-y;
      margin: 0;
    }
    
    #right {
      width: 100px;
      float: right;
      background: #3e97f3 url('http://www.epalsconnect.com/clinic/images/rightBg.jpg') left repeat-y;
    }
    
    #content { 
      height: 100%;
      margin-left: 100px;
      margin-right: 100px;
      background: #ffffff url('http://www.epalsconnect.com/clinic/images/contentBg.gif') bottom right no-repeat;
    }
    Last edited by GarrettVD; 12-21-2007 at 08:22 AM. Reason: Removed the excessive "CODING"s

  • #5
    Senior Coder effpeetee's Avatar
    Join Date
    Feb 2007
    Location
    Clapham Junction - London SW
    Posts
    4,885
    Thanks
    228
    Thanked 204 Times in 203 Posts
    All the columns look the same height to me. Both IE7 and FFox 2.

    Frank
    * Sources (updated: 21.11.2012.
    Using Windows 8 Professional. 64bit with HP Photosmart 5510 printer Very useful site here.

  • #6
    Regular Coder
    Join Date
    Nov 2006
    Posts
    247
    Thanks
    13
    Thanked 26 Times in 24 Posts
    @ Frank: They're not. He has a gradient on each of the right and left columns. It's hard to notice if you're not looking right at it, but it's there. You can only see it behind the text.

    -----

    Now, the short version is getting a div to span the same height as that of another is impossible. When people have 2 column layouts and they want to accomplish this, they have a wrap around the left and right columns with a vertically repeating background image. This way, the wrap spans the height of the longest column (no matter which) and so does it's background image. The illusion is 2 columns that appear to span the same height.

    Doing it with 3 columns is a bit more difficult. Did come up with a solution for you though. Here:

    replace CSS with:
    Code:
    body { 
      font-family: Arial, Helvetica, sans-serif;
      text-align: left;
      background: #3e97f3 url('http://www.epalsconnect.com/clinic/images/leftBg.jpg') top left repeat-y;
    }
    
    html {
      height: 100&#37;;
    }
    
    * {
    margin: 0;
    padding: 0;
    border: none;
    }
    
    #wrap {
      width: 1000px;
      height: 100%;
      margin: 0 auto;
      text-align: left;
      min-height: 100%;
      background: transparent url('http://www.epalsconnect.com/clinic/images/rightBg.jpg') top right repeat-y; 
    }
    
    * {
    	margin: 0;
    	padding: 0;
    }
    
    * html #wrap {
    	height: 100%
    }
    
    p {
      margin: 0;
      padding: 0px;
    }
    
    #left {
      float: left;
      width: 100px;
      margin: 0;
    }
    
    #right {
      width: 100px;
      float: right;
    }
    
    #content { 
      height: 100%;
      margin-left: 100px;
      margin-right: 100px;
      background: #ffffff url('http://www.epalsconnect.com/clinic/images/contentBg.gif') bottom right no-repeat;
    }
    Wont have to change your HTML.

    Should work. Good luck.
    Last edited by Majoracle; 12-21-2007 at 10:02 AM.

  • #7
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,675
    Thanks
    22
    Thanked 1,827 Times in 1,811 Posts
    However, if you take a look at my website, the left and right columns are not extending to the same length as that of the Content column. Setting the height: 100% will only ensure that the first 100% is filled with background image, but what about the rest? Is there a way to fix this?
    Good morning GarettVD, Have a look at this:http://nopeople.com/CSS/full-height-3column/
    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

  • #8
    New to the CF scene
    Join Date
    Apr 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks again, guys! Very helpful information. I've gone with the easiest, and possibly best choice of setting just one body background image, which will repeat-y, centered, for the length of the page. Doing it the other way is too much hassle for what it's worth.

    Thanks!


  •  

    Posting Permissions

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