This is a very common scenario, I think.
I'm relatively (not a pun) new to CSS, and I have a problem with float alignment. I have two divs, one of which will contain the main content for swimming left, and the other for navigation, which should be floating right.
Anyway, this is what happens when I don't use CSS formatting. This is the desired behavior; the page will scroll as expected:
Desired behavior
Here's what happens when I apply to float: leftor float: rightto the relevant elements:
Unwanted page overflow
They both overflow the page. I want him to stretch the page so that it scrolls down if it is not suitable for one area of the screen.
Excerpt from my HTML:
<body>
<div id="wrapper">
<div id="header"></div>
<div id="content">
<div id="main">
<p>Lorem ipsum [...snip...]</p>
</div>
<div id="secondary">
<p>Lorem ipsum [...snip...]</p>
</div>
</div>
<div id="footer">©</div>
</div>
</body>
And the corresponding CSS:
#content {
padding:10px;
padding-top: 110px;
padding-bottom:60px;
}
#main {
padding: 10px;
float: left;
width:70%;
text-align:left;
}
#secondary {
padding: 10px;
float: right;
width:20%;
}
Why is he doing this and how can I fix it?
Corey source
share