Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / HTML, CSS, Scripts / CSS / April 2006



Tip: Looking for answers? Try searching our database.

2 Column Layout using Floats

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Joel Byrd - 25 Apr 2006 20:51 GMT
I've got a 2-column tableless layout and I'm using floats to render the

columns.  Here are the basic style definitions for the 2 columns:

       #left_col {
               width: 59%;
               float: left;
               clear: left;
       }

       #right_col {
               width: 39%;
               float: right;
               clear: right;
               }

This works fine and allows dynamic column widths.  Note that the
heights of the columns are independant of each other.  The problem I'm
having is getting a footer to show up at the bottom of these columns.
It actually works fine in IE, but not in other browsers (I've tried
Firefox and Opera).  What happens is that the footer shows up at the
bottom of whichever column is last in the HTML code.  And I've got the
2 columns wrapped inside a div, but I still get the same result.

The basic html is:

[-----------

<div id="wrapper">

 <div id="left_col">
   some content.
 </div>

 <div id="right_col">
   some content.
 </div>

</div>

<p>This is the footer.</p>

-------------]
David E. Ross - 25 Apr 2006 22:08 GMT
> I've got a 2-column tableless layout and I'm using floats to render the
>
[quoted text clipped - 39 lines]
>
> -------------]

For the <p> at the start of the footer line, add an in-line style or a
reference to a style-sheet that has "clear:both".

Signature

David E. Ross
<http://www.rossde.com/>

Concerned about someone (e.g., Pres. Bush) snooping
into your E-mail?  Use PGP.
See my <http://www.rossde.com/PGP/>

Joel Byrd - 25 Apr 2006 22:26 GMT
Yes, thank you - I found out that this is the basic idea behind the
solution.  Well, actually, it is adding a div with "clear: both" at the
end of the div that is wrapping the 2 floated columns.  But an even
better way to do this does not require adding anything to the html and
is the .clearfix class as documented here:
http://www.positioniseverything.net/easyclearing.html - I think this is
a very good solution.
Jim Moe - 26 Apr 2006 08:12 GMT
> [...] But an even
> better way to do this does not require adding anything to the html and
> is the .clearfix class as documented here:
> http://www.positioniseverything.net/easyclearing.html - I think this is
> a very good solution.

 David did mention to add or modify the class for the <p> that contained
"clear:both". No need for inline styles or an extra <div>.
 The ".clearfix" is meant to create a uniformity of presentation between
IE and the world for the way floated elements wrap content. It has no
advantage for your case except the "clear:both" rule. So all the other
rules in .clearfix are dead weight.

Signature

jmm (hyphen) list (at) sohnen-moe (dot) com
(Remove .AXSPAMGN for email)

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.