Centring Floated Divs With Clearing Divs
text-align:centre; - Placed in the CSS code for "body"
margin:0 auto; - Placed in the CSS code for "wrapper"
When using two column the wrapper must contain two floated divs. Since browsers interpret floats in different ways sometimes it is necessary to use a clearing div. When the wrapper is centred and the columns are floated a problem is presented to us in Firefox. The wrapper does not expand as the columns inside it do. The way we can get the wrapper to expand is to use a clearing div. A clearing div acts as a blank div placed just under the two columns to make the wrapper expand. This is a useful technique which does not involve browser hacks. To do a clearing div put the following in your CSS:
.clear { width: 100%;
height: 1px;
margin: 0 0 -1px;
clear: both; }
Now under the two columns or under a div which is not causing the wrapper to expand simple add the following code:
This is a useful and simple technique. It can be used for many different situations when coding a website.
About the Author
Loads of other free CSS articles, tutorials and templates can be found at my CSS website. My CSS website is http://www.freecss.info.
Webmaster Related Information & Resource Sites:
Domain Buffs
Parking PPC
PPC Ad Income: Website Monetization
Apache Website Hosting
Design Dirt
Dynamite Flash
Open Source Web Zine
foo site: Website Coding
php Web Development
American Webmastery
Meta Tag SEO
Target: Page 1 Search Result Rankings
Ad Working
Yahooter?
Websites of Various Interests:
US Auto & Truck
Auto Czar
Hybrid Autos
Race Footage
HDTV WideScreen
Hi Def Discs
High-Def.Info
XBOX & PC
XBOX MC
X-Bx: XBOX Entertainment System
RFID Technology
Mom's Cuisine
Healthy Cooking: Broil.Info
Nuptial Businesses
Honorable Intent
Gunmanship
A Dog is a Man's Best Friend
Mission: Planet
Footrace.org
