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.

Fixing the two-column problem<br />

Are you sitting there waiting for us to come riding in on a white horse <strong>with</strong><br />

the magic property that solves all this? Well, that’s not going to happen.<br />

This is the point in <strong>CSS</strong> where page layout becomes more an art – or at<br />

least a set of techniques – than a set of properties that can solve every<br />

problem. So, what we’re going to do is solve this using a common technique<br />

that is widely used. It’s not perfect, as you’ll see, but in most cases it gives<br />

you good results. And after this, you’re going to see a few other ways to<br />

approach the same two-column problem. What’s important here is that you<br />

understand the techniques, and why they work, so you can apply them to<br />

your own problems, and even adapt them where necessary.<br />

So, what if we give the main<br />

content area a right margin<br />

that is at least as big as the<br />

sidebar? Then its content will<br />

extend almost to the sidebar,<br />

but not all the way.<br />

layout and positioning<br />

The first thing to<br />

remember is that the<br />

sidebar is floating on<br />

the page. The main<br />

content area extends<br />

all the way under it.<br />

Then we’ll have separation between<br />

the two, and since margins are<br />

transparent and don’t show the<br />

background image, the background<br />

color of the page itself should show<br />

through. And that’s what we’re<br />

looking for (flip back a few pages<br />

and you’ll see). Let’s make the margin as<br />

wide as the sidebar.<br />

you are here 507

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

Saved successfully!

Ooh no, something went wrong!