Floating Divs And Container Height Fix
Almost any web designer meets at the beginning some frequent problems when using floating layouts. We know that if we want to use two or more columns in our web design, we should use floating layout. That means that we have a container div and two or more floating divs inside.
What is the problem?
The web design world doesn't act like a graphic design sketch, and sometimes we are dealing with complicated issues just to place a small element. Our container div doesn't get any height setting because we want it to be a flexible; we want it to be depended on the floating column's height. By default, the container won't get any height, it will be 0px height and the columns will flow out of the box.
Here comes the big design problem. The next div, right after the last div in the line (usually it will be the "float: right;" div), will stick to the container div without considering the floating divs height. You have no idea how your design looks right now.
<div style="width:100%;">
<div style="width:50%; float:left;"></div>
<div style="width:50%; float:right;"></div>
</div>
<div style="width:100%;"></div>
You can see in the image above how the red div stuck to the top of the container, together with the floated divs.
The solution
The problem is floating, so the solution is floating. If the container won't be stretched together with its floating content, we will force it with non-floated div.
After we finish the entire floating layout we place a clear div right before we are closing the container, its style will be "clear: both;". This way we get non-floating element, and the container will have to stretch its height to merge with the end of it.
<div style="width:100%;">
<div style="width:50%; float:left;"></div>
<div style="width:50%; float:right;"></div>
<div style="clear:both;"></div>
</div>
<div style="width:100%;"></div>
Shorter solution
Another way to fix this is to add "overflow: auto;" to the container (no need clear div). This way we force the container to act as a flexible element. In old versions of IE it won't get this as a layout, so we add width to the container to tell the browser it's a layout div.
<div style="width:100%; overflow:auto;">
<div style="width:50%; float:left;"></div>
<div style="width:50%; float:right;"></div>
</div>
<div style="width:100%;"></div>
Now you can see how the container wrapping the floated divs, the bottom div can get full visibility now.
News
CMSOur new management system designed to provide 100% tracking and managing stores online. The new system built by the highest technology, and this provides more power by less size and more flexibility by less pages.
iPhone AppsWe start our new firm in New-York of iPhone™, iPod™ & iPad™ Apps development. We are in process of 5 new apps that never seen before.
New projects
Imani Chocolatiers LLC is a new growing business in the candy and gifts industry. This website has been designed and programmed by SMooVo for ecommerce use, and it is using our new CMS for shopping carts, orders management and products management.
Technology used: HTML5, CSS, JavaScript, jQuery, PHP, MySQL, Photoshop CS4, Flash CS4, ActionScript3.0.
This website been made for professional locksmith company in NY. We are managing their website and their SEO. It is made with template.
New Testimonials
"It is scary to invest money while you trying to grow, but with Smoovo it's a different story. From the beginning they helped us to understand and believe in our goal, and they give us the idea behind the web design."
Eli, NY
"I'm so happy with their work; they have put my business on line. I have more customers and I'm keeping get compliments about my online business."
Roi, AZ
"Even though I am in Australia and Smoovo is in the USA, my project developed by Smoovo, could not of gone better. Nothing was a problem and Smoovo's business manner was impeccable. If you need website development I highly recommend the guys at Smoovo."
Parrish, Australia
"smoovo is by far the most reliant and responsive team I have ever worked with. They go far and beyond your project expectations and have so much knowledge and input into your project that it's as if they are your partners in business. It's always a pleasure working with them and they are very reasonably priced."
Oded, New-York