HTML and CSS Reference
Solving the overlap problem
To fix our overlapping problem, we're going to use
another CSS property that you haven't seen yet: the
clear property, and here's how it works…
Here's what we 've got now. The
“main” <div> is short en ough
that the foot er <div> is comin g
right up and o verlappin g with
the si debar <d iv>.
This happens b ecause the sidebar has been pulled out of the flow.
So, the brows er just lays out the main and footer <div>s like it
normally would , ignoring the sidebar (although remember that when
the browser f lows inline elements, it will respect the borders of
the sidebar an d wrap inline elements around it).
You can use the CSS clear property on an element to request that as the element is
being flowed onto the page, no floating content is allowed on the left, right, or both
sides of the element. Let's give it a try…
Her e we're a dding a property to
the footer rule, whic h says t hat
no floating content is allowe d on
the right of the foo ter.
Now when the browser places the
elements on the page, it looks to see if
there is a floating element to the right
side of the footer, and if there is, it
moves the footer down until there is
nothing on its right. Now, no matter
how wide you open the browser, the
footer will always be below the sidebar.
think about putting
a floating element to
the right of me.