Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-04-2008, 02:22 PM   PM User | #1
Lc3
New to the CF scene

 
Join Date: Dec 2008
Posts: 2
Thanks: 2
Thanked 0 Times in 0 Posts
Lc3 is an unknown quantity at this point
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.
Lc3 is offline   Reply With Quote
Old 12-04-2008, 02:39 PM   PM User | #2
jerry62704
Senior Coder

 
jerry62704's Avatar
 
Join Date: Oct 2007
Location: Springfield, IL
Posts: 1,077
Thanks: 13
Thanked 84 Times in 84 Posts
jerry62704 is on a distinguished road
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
jerry62704 is offline   Reply With Quote
Users who have thanked jerry62704 for this post:
Lc3 (12-04-2008)
Old 12-04-2008, 04:46 PM   PM User | #3
Excavator
Master Coder


 
Excavator's Avatar
 
Join Date: Dec 2006
Location: Alaska
Posts: 9,410
Thanks: 22
Thanked 1,765 Times in 1,749 Posts
Excavator has a spectacular aura aboutExcavator has a spectacular aura aboutExcavator has a spectacular aura about
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
Excavator is offline   Reply With Quote
Users who have thanked Excavator for this post:
Lc3 (12-04-2008)
Old 12-04-2008, 05:57 PM   PM User | #4
Lc3
New to the CF scene

 
Join Date: Dec 2008
Posts: 2
Thanks: 2
Thanked 0 Times in 0 Posts
Lc3 is an unknown quantity at this point
Lovely. I prefer your way Excavator but thanks jerry62704 too your wayalso works. This problem had me completely lost.

Lc3 is offline   Reply With Quote
Reply

Bookmarks

Tags
colums, css, firefox, float, html

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:22 AM.


Advertisement
Log in to turn off these ads.