04.06.2013 Views

Head First HTML with CSS

Head First HTML with CSS

Head First HTML with CSS

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Test drive<br />

As usual, save your “starbuzz.css” file and then<br />

reload “index.html”. You should now see a<br />

nice gutter between the two columns. Let’s<br />

think through how this is working one more<br />

time. The sidebar is floating right, so it’s been<br />

moved as far to the right as possible, and the<br />

whole has been removed from the<br />

normal flow and is floating on top of the page.<br />

Now the main content is still taking<br />

up the width of the browser (because that’s<br />

what block elements do), but we’ve given it a<br />

margin as wide as the sidebar to reduce the<br />

width of the content area. The result is a nice<br />

two column look. You know the box of the<br />

main still goes under the sidebar, but<br />

we won’t tell anyone if you don’t.<br />

By expanding the margin<br />

of the main , we’re<br />

creating the illusion of a two<br />

column layout, complete <strong>with</strong><br />

a gutter in between.<br />

We’ve got a problem. When you resize your browser to a<br />

wide position, the footer and the sidebar start to overlap.<br />

layout and positioning<br />

Uh oh, we have<br />

another problem<br />

As you were test driving the<br />

page you might have noticed<br />

a little problem. If you<br />

resize the browser to a wide<br />

position, the footer comes up<br />

underneath the sidebar. Why?<br />

Well, remember, the sidebar<br />

is not in the flow, so the footer<br />

pretty much ignores it, and<br />

when the content area is too<br />

short, the footer moves right up.<br />

We could use the same margin<br />

trick on the footer, but then the<br />

footer would only be under the<br />

content area, not the whole<br />

page. So, what now?<br />

you are here 509

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!