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 4 of 4
  1. #1
    Lc3
    Lc3 is offline
    New to the CF scene
    Join Date
    Dec 2008
    Posts
    2
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Unhappy Attempting 2 Col Layout in wrapper, wrapper wont expand to float

    Hi, I'm sure I'm not the first one to come accross this but I can't find a solution for it online. Here is a boiled down sample HTML/CSS page of what I'm trying to do:

    http://leechristie.com/hotlinks/css-help/example.html <- View the source of this HTML document

    I made that simple example rather than post my origonal page, since my origonal page is covered in PHP and would complicate my question.

    Here's what the sample page looks like on IE (this is what I'm going for):



    But on FireFox the wrapper collapses when the side is longer than the main area:



    Since I'll have a black border around my wrapper,that would be noticeable.

    Can anyone please tell me what I need to add to my CSS to fix it to display correctly on all browsers? View the source on the HTML document I linked to have a look, thanks.

  • #2
    Senior Coder jerry62704's Avatar
    Join Date
    Oct 2007
    Location
    Springfield, IL
    Posts
    1,100
    Thanks
    13
    Thanked 87 Times in 87 Posts
    This will do what you want:

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
                "http://www.w3.org/TR/html4/strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
        <style>
    
            * {
                margin: 0px;
                padding: 0px;
                border: 0px;
                text-align: left;
            }
    
            ul {
                list-style: none;
            }
    
            body {
                text-align: center;
            }
    
            #wrapper {
                padding: 20px;
                border: 1px solid black;
                width: 800px;
                margin: 20px auto 20px auto;
            }
    
            #main {
                padding: 10px;
                border: 1px solid red;
                margin-right: 290px;
            }
    
            #side {
                padding: 10px;
                float: right;
                width: 250px;
                border: 1px solid blue;
            }
            #clearit {
            	clear:	both;
            }
    
        </style>
      <title>Example</title>
      </head>
      <body>
        <div id="wrapper">
          <div id="side">
            <ul>
              <li>Big</li>
              <li>Long</li>
              <li>List</li>
              <li>With</li>
              <li>Lots</li>
    
              <li>And</li>
              <li>Lots</li>
              <li>Of</li>
              <li>Items</li>
            </ul>
          </div>
    
          <div id="main">
            <p>A little text in the main body here.</p>
          </div>
    		<div id="clearit">&nbsp;</div>
        </div>
      </body>
    </html>
    I cleared the float with another div so the wrapper would also clear it. Works in both FF3 and IE6.
    .
    .
    ...and gladly would he learn and gladly teach

    Visit www.LiberalsWin.com for humor and the unique Bush/Obama Approval Polls

  • Users who have thanked jerry62704 for this post:

    Lc3 (12-04-2008)

  • #3
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,748
    Thanks
    22
    Thanked 1,838 Times in 1,822 Posts
    Hello Lc3,
    I much prefer another method of clearing, like this:
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
                "http://www.w3.org/TR/html4/strict.dtd">
    <html>
      <head>
        <style>
    
            * {
                margin: 0px;
                padding: 0px;
                border: 0px;
                text-align: left;
            }
    
            ul {
                list-style: none;
            }
    
            body {
                text-align: center;
            }
    
            #wrapper {
                padding: 20px;
                border: 1px solid black;
                width: 800px;
                margin: 20px auto 20px auto;
    overflow: auto;
            }
    
            #main {
                padding: 10px;
                border: 1px solid red;
                margin-right: 290px;
            }
    
            #side {
                padding: 10px;
                float: right;
                width: 250px;
                border: 1px solid blue;
            }
    
        </style>
      <title>Example</title>
      </head>
      <body>
        <div id="wrapper">
          <div id="side">
    
            <ul>
              <li>Big</li>
              <li>Long</li>
              <li>List</li>
              <li>With</li>
              <li>Lots</li>
    
              <li>And</li>
              <li>Lots</li>
              <li>Of</li>
              <li>Items</li>
            </ul>
          </div>
          <div id="main">
    
            <p>A little text in the main body here.</p>
          </div>
        </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:

    Lc3 (12-04-2008)

  • #4
    Lc3
    Lc3 is offline
    New to the CF scene
    Join Date
    Dec 2008
    Posts
    2
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Lovely. I prefer your way Excavator but thanks jerry62704 too your wayalso works. This problem had me completely lost.



  •  

    Tags for this Thread

    Posting Permissions

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