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.

using margins for two columns<br />

Sharpen your pencil<br />

508 Chapter 12<br />

What we want to do is set a right margin on the main content section so that it’s<br />

the same width as the sidebar. But how big is the sidebar? Well, we hope you<br />

aren’t already rusty since the last chapter. Here’s all the information you need to<br />

compute the width of the sidebar. Check your answer in the back of the chapter.<br />

#sidebar {<br />

background: #efe5d0 url(images/background.gif) bottom right;<br />

font-size: 105%;<br />

padding: 15px;<br />

margin: 0px 10px 10px 10px;<br />

width: 280px;<br />

float: right;<br />

}<br />

Setting the margin on the main section<br />

#main {<br />

}<br />

You’ll find everything you<br />

need to compute the width<br />

of the sidebar in this rule.<br />

The width of the sidebar is 330 pixels, and that includes 10 pixels of left margin on<br />

the sidebar, which will provide the separation we need between the two columns<br />

(what the publishing world calls a “gutter”). Add the 330 pixel right margin to the<br />

#main rule in your “starbuzz.css” file, like we’ve done below:<br />

background: #efe5d0 url(images/background.gif) top left;<br />

font-size: 105%;<br />

padding: 15px;<br />

margin: 10px;<br />

margin: 0px 330px 10px 10px;<br />

We’re changing the right margin to 330 pixels<br />

to match the size of the sidebar.

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

Saved successfully!

Ooh no, something went wrong!