04.06.2013 Views

Head First HTML with CSS

Head First HTML with CSS

Head First HTML with CSS

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Test driving <strong>with</strong> a tank of jello<br />

Add the two margin properties to your “starbuzz.css” file, and then reload<br />

the page. Now play <strong>with</strong> the size of the browser. Pretty nice, huh?<br />

Narrow.<br />

Wide.<br />

So if we want our content<br />

in the correct order, we either<br />

have to live <strong>with</strong> an expanding<br />

sidebar or we have to use a jello<br />

layout? Is there any other way to<br />

do this?<br />

With <strong>CSS</strong>, there are typically lots of ways to approach a layout, each <strong>with</strong> their<br />

own strengths and weaknesses. Actually, we’re just about to look at another<br />

common technique for creating a two-column layout that keeps the content in<br />

the correct order, and avoids some of the problems of the liquid layouts. But,<br />

as you’ll see, there are some tradeoffs.<br />

With this new technique we’re not going to float elements at all. Instead we’re<br />

going to use a feature of <strong>CSS</strong> that allows you to precisely position elements on<br />

the page. It’s called absolute positioning. You can also use absolute positioning<br />

for some nice effects beyond just multi-column layouts, and we’ll look at an<br />

example of that, too.<br />

layout and positioning<br />

To do all this, we’re going to step back to the original X<strong>HTML</strong> and <strong>CSS</strong> we<br />

started <strong>with</strong> in the beginning of this chapter. You can find a fresh copy of these<br />

files in the “chapter12/absolute” folder. Be sure and take another look at these<br />

files so you remember what they originally looked like. Recall that we’ve got<br />

a bunch of s: one for the header, one for main, one for the footer, and<br />

also a sidebar. Also remember that in the original X<strong>HTML</strong>, the sidebar <br />

is below the main content area, where we’d optimally like to have it.<br />

you are here 519

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

Saved successfully!

Ooh no, something went wrong!