13.02.2013 Views

WEB STANDARDS CREATIVITY

WEB STANDARDS CREATIVITY

WEB STANDARDS CREATIVITY

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

Strictly speaking, these class names might not be the most ideal. In general, try to avoid using class or ID values<br />

that represent the way an element will be displayed to the user (such as red-link, big-headline, or even<br />

ad-column-300). The main reason for avoiding these “presentational” names is that they’re not especially<br />

future-proof: what happens when you redesign your site, and all of those red-link elements need to be<br />

green? ad-layout-1 or ad-layout-2 might have been more abstract, and perhaps a bit better; however, we<br />

decided that the production staff might better manage the more descriptive names, and the rest is history. Or<br />

class names. Or something.<br />

In effect, this gives our template a kind of toggle that we can exploit with our CSS. If we know that one of these two templates<br />

will be applied to our body element, we can modify our style rules accordingly:<br />

/*<br />

Set the column offset on the content DIVs<br />

*/<br />

body.ad-column-180 #content-primary-wrap {<br />

margin-right: -200px;<br />

}<br />

body.ad-column-180 #content-primary {<br />

margin-right: 200px;<br />

}<br />

body.ad-column-300 #content-primary-wrap {<br />

margin-right: -370px;<br />

}<br />

body.ad-column-300 #content-primary {<br />

margin-right: 370px;<br />

}<br />

/*<br />

Set the right-hand column width<br />

*/<br />

body.ad-column-180 #content-secondary {<br />

width: 190px;<br />

}<br />

body.ad-column-300 #content-secondary {<br />

width: 360px;<br />

}<br />

Here, we flesh out our original rules and prepare for the two separate column widths with the appropriate body.ad-column-180<br />

and body.ad-column-300 selectors.<br />

chapter 3 New York Magazine: My, What a Classy <br />

63

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

Saved successfully!

Ooh no, something went wrong!