13.02.2013 Views

WEB STANDARDS CREATIVITY

WEB STANDARDS CREATIVITY

WEB STANDARDS CREATIVITY

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.

So there we have it: a single class value on our body attribute can act as a kind of traffic cop for each module on our sidebar.<br />

We’ve written some CSS that expects (and exploits) the presence of either ad-column-180 or ad-column-300, leaving<br />

our markup completely untouched.<br />

Additional classes, additional control<br />

At this point, we’ve been using one value in the class attribute. By using ad-column-180 or ad-column-300, we can instantly<br />

reformat our right sidebar and its contents. As we’ve discussed, the class attribute can accept multiple values, but can we<br />

use the body element to control other aspects of our page’s presentation? There I go with the leading questions again.<br />

Starting small (980 pixels’ worth)<br />

When I came on board with the New York Magazine website redesign, I was told that the production team wanted to be able<br />

to selectively override the flexible-width design on certain pages, effectively fixing the page’s width at the full 980 pixels.<br />

Presumably, some of the pages would contain wide-format media (e.g., large photographs), and the client wanted to ensure<br />

that the rest of the page’s layout would remain intact.<br />

Let’s take another look at our #wrap rule, which contains our min-width and max-width parameters:<br />

#wrap {<br />

margin: 0 auto;<br />

min-width: 770px;<br />

max-width: 980px;<br />

}<br />

So if this is the default behavior, let’s add a new class value to our body element to override it—say, “fixed”?<br />

<br />

We can now drop in the following CSS to turn our flexible design into a static one:<br />

body.fixed #wrap {<br />

width: 980px;<br />

}<br />

And there we have it. Since we’ve now set a width on our wrap block, the min-width and max-width properties are obsolete.<br />

Our design’s container div is fixed at the requested 980 pixels, which fulfills our client’s request.<br />

A word of caution about multiple class names: The aged IE5/Mac has a whitespace parsing bug<br />

(www.macedition.com/cb/ie5macbugs/substringbug.html) that can cause it to become confused when<br />

encountering a class name that is a substring of another class. As a result, try to make the categories of<br />

class types you’re applying as unique as possible, and test thoroughly in that browser.<br />

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

71

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

Saved successfully!

Ooh no, something went wrong!