Categories: Css

Clearing floats

Share

For a float based layout the common problem is that the container doesn’t stretch up. Try Clearing floats. For example if you want to add floats then using command the browsers it stretch up the container all the way.

Suppose we are using the below css through out the page:

 div.container {
 border: 2px solid #cccccc;
 }
 div.left {
 width: 40%;
 float: left;
 }
 div.right {
 width: 40%;
 float: right;
 }

in this case as the container div has o height then it contains floating elements. That is why the border stays at top of floating columns.

You can add a extra element with clear: both to solve this. But here is another solution:

div.container {
 border: 2px solid #cccccc;
 overflow: auto;
 width: 100%
 }

Recent Posts

Editorial Elevation: Refined Writing Services

Introduction The influence of words is more significant than ever in a digital age. Whether…

2 days ago

How to Start a Business?

How to Start a Business begins with the realization that every business has its risks and…

2 days ago

4 Tips for Businesses Struggling with Cash Flow

It's not uncommon for businesses to have financial difficulties nowadays. The fact of the matter…

2 days ago

Top Advantages of Augmented Reality in Healthcare

The success of any tech innovation depends on its share in various industries and business…

2 days ago

Recover From Google Penalties in 10 Steps in 2024

Facing Google penalties can be a daunting challenge for businesses relying on organic search traffic.…

3 days ago

What is the Future of Artificial Intelligence?

Technology, undeniably, has made our lives easier. But the advent of artificial intelligence has been…

3 days ago