473,592 Members | 2,921 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

2 Column Layout using Floats

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>
-------------]

Apr 25 '06 #1
3 2176
Joel Byrd wrote:
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>
-------------]


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 ".

--

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/>
Apr 25 '06 #2
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.

Apr 25 '06 #3
Joel Byrd wrote:
[...] 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.

--
jmm (hyphen) list (at) sohnen-moe (dot) com
(Remove .AXSPAMGN for email)
Apr 26 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
5463
by: Doug McCrae | last post by:
http://www.btinternet.com/~doug.mccrae/go4learning/index.html As it says in the subject, a two column layout (plus header and footer boxes). I feel the left column really needs to be fixed width (151px) as it contains an image, while everything else is fluid. However this only works in IE 6.0. In Netscape and Opera I found that the auto width of the right column is 100% so it jumps down below the menu if the left column is fixed - not...
4
3101
by: Stian Lund | last post by:
Hi, I'm trying to create a 2 column layout with a footer on the bottom, where the (fixed-width) sidebar follows the content in the code, while showing on the left hand side of the content. The footer must stay at the bottom regardless of which column is the longest, so absolute positioning is out, I need to use floats with the clear: both; - property on the footer. Doing this with the sidebar *before* the content in the code I know how
4
2564
by: Spartanicus | last post by:
I've started work on a css layout tutorial. I expect that it will take a minimum of several weeks to get to a complete draft stage. I hope to get better feedback by publishing individual pages. I've uploaded 2 draft pages, an index and a list of definitions: http://www.spartanicus.utvinternet.ie/CssLayout/index.htm.remove http://www.spartanicus.utvinternet.ie/CssLayout/definitions.htm.remove The urls are not valid because of the added...
30
3116
by: Diane Wilson | last post by:
I'm trying (once again) to figure out how to make a robust CSS layout style that can replace tables. I'd like to be able to do a basic two-column layout, with a one-column header, a two column body, and a two-column footer. The problem, and one that always sends me back to using tables, is that word "robust." Absolute positioning gets squirrelly, because it takes the positioned elements completely out of the float scheme, and stuff...
9
2387
by: WeshaTheLeopard | last post by:
Hi all, I have to admit that I'm completely at loss trying to implement the following layout: +-----------document---------+ | | | +--box1---+ +--box2---+ | | | A | | A | |
7
2610
by: Andrew | last post by:
I've been struggling to achieve the following layout for some time now and I'm not getting anywhere. I've tried several approaches including floats & absolute positioning and none seem to work, primarily due to the footer not being aware of the columns due to me floating / positioning them. I have the following (very simple) markup: <div id="head">...</div> <div id="left">...</div>
9
1833
by: Xavier van Unen | last post by:
Hi guys and gals, I'm working on a 2 column CSS layout (for an ordering system) in which it isn't a priori known which of the two columns will be the longest, that depends on the (script generated) content. As there is also a following footer DIV, the usual floating one of the DIVs technique doesn't give the desired results, and has the floated DIV (if it is the longest one) being displayed/rendered through the footer DIV. I...
16
3021
by: Jef Driesen | last post by:
I have created a nice idea for a website and now I would like to translate that idea in (x)html and css. The layout is quite basic: a header, two columns and a footer. For a graphical presentation, see http://users.telenet.be/sacn/tmp/layout.png. I would like to have: * source ordered columns: header, content, sidebar, footer * fixed width columns (either px or em units). Because I don't like reading very long lines and IE does not...
27
2835
by: FuzzyLogik | last post by:
http://phazm.net/csstest/index2.html I'm trying to make the thumbnails fit to the width of the page, so there are 3-4 in each row, but when you resize, I want it to basically flow with the page, and I'm having a bit of a hard time figuring that out. I want the code to remain logical: <ul>
0
7935
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7871
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
6642
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5735
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5400
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3893
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2379
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1467
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1202
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.