The easy way to clear floated elements

by Alex Kondys on May 28th, 2010 | Posted in Revium Sandbox | Comment on this entry

Floating elements using CSS is a good way to lay out items on a page, but when some elements are floated they lose their space in the flow if items, which results in the overlapping of elements.

The easy way to do this is to create a new element, typically a div, with a clear attribute and add it after the container with the floated elements inside. This in theory is good, but if you need to clear a lot of items, this task can get tedious.

The easy way to clear floated elements I came across a little while ago is very straight forward. Assuming you have a div containing your floated elements (in this example we’ll use a class of container) just add the following CSS.

div.container {
	height: 100%
	overflow: auto;
}

With this method being around for a while now, there are plenty of more detailed explanations around the web if you need more information, and I would recommend giving this post a read first and see if it answers your questions, http://www.quirksmode.org/css/clearing.html.

Related posts:

  1. ASP.NET selectors in jquery
  2. Developing faster web forms in .NET

« Unique Arrays in PHP

ASP.NET Button – prevent double clicks part 2 »

Leave a Reply

Click here to cancel reply.

Recent Articles

  • Return of the daily sites
  • Collaborating with Government
  • Ya-bing-ooo!! Yahoo search is dead long live the Bing.
  • Social Media – Good For Some
  • 10 Tips for user acceptance testing of web applications
  • Popular Content Management Systems
  • ASP.NET MVC [HandleError] and logging
  • VMWare hard lessons

Twitter

  • Collaborating with Government: Revium is actively involved in the Federal Government’s R&D program for tax concess... http://bit.ly/9D7Vc6 1 week ago
  • 45 Free Applications For Web Designers & Developers http://www.noupe.com/tools/45-free-applications-for-designers-and-developers.html 1 week ago
  • In most watch advertisements the time displayed on the timepiece is 10:10 because then the arms frame the brand of the watch. 1 week ago
  • More updates...

Revium Logo

  • Home
  • About
  • Expertise
  • Showcase
  • Contact

  • news
  • blog
  • sandbox
  • twitter
  • facebook
  • rss
Bookmark and Share

We are Revium, hear us roar!

The news.

31 Aug

Collaborating with Government

Revium is actively involved in the Federal Government’s R&D program for tax concessions to develop our in-house products that we are looking to take…

Continue reading
View archive

The blog.

01 Sep

Return of the daily sites

Years ago I used to have a morning routine of checking a select few websites I came across. For one reason or another I…

Continue reading
View archive

The sandbox.

20 Aug

Ya-bing-ooo!! Yahoo search is dead long live the Bing.

Ya-bing-oo!! Yahoo search is dead long live the Bing In July 2010 Yahoo had started testing Bing powered search they routed 25% of their search…

Continue reading
View archive

eNewsletter.

 

© Copyright 2010. All Rights Reserved.

Revium Pty Ltd

e / info@revium.com.au t / Work +61 3 9429 2000

Find us: web development, seo

Disclaimer and privacy Revium Pty Ltd

10 Harvey Street
Richmond, Victoria, 3121 Australia
View map

Logo Partner MicrosoftLogo Partner KenticoLogo Partner IiaLogo Partner Iia RibLogo Partner Acs