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.

Creating the illusion of vertical text<br />

The headings that should be vertical are all static. Since they don’t need to be regularly updated, I can use images rendered<br />

in Photoshop. The vertical text effect isn’t easy to reproduce any other way. I could do it with Flash, but it’s easier with this<br />

method, as the sIFR approach (discussed next) doesn’t support rotated text, and Flash items can be more difficult to position.<br />

I could just use the CSS background-image property to assign each image to a container , but there’s no actual<br />

heading within the HTML file, and that’s not an ideal situation if the markup is to be accessible, even if on a basic level.<br />

The good news is that it’s just as easy to make an HTML heading (, , and so on) do exactly what I want, and for<br />

somewhat obvious reasons, this approach is called image replacement. There are about as many ways to handle image<br />

replacement as there are versions of Internet Explorer with weird CSS bugs, but I prefer a method devised by Mike Rundle<br />

dubbed the Phark method (after his personal site, http://phark.net). Let’s use one of our sidebar headings (wrapped in a<br />

module ) as an example:<br />

<br />

videos<br />

<br />

For more on image replacement techniques, Dave Shea has compiled a nice comparison for you to bookmark<br />

and reference: http://mezzoblue.com/tests/revised-image-replacement/.<br />

Without any specific styling, this heading will display just as you would expect. But the idea is to hide the default text output<br />

and replace it with the text image created in a graphics editor, and the following CSS rule is all I need:<br />

#sidebar .module h3 {<br />

background:url(i/header_module_events.gif) no-repeat;<br />

width:18px;<br />

height:58px;<br />

margin:0;<br />

text-indent:-5000px;<br />

}<br />

This rule handles the following:<br />

Set the background image and instruct the browser to not tile the image.<br />

Define the dimensions (set here to equal the width and height of the background image).<br />

Kill the margins. It’s a good idea to zero your margins when replacing headings, and then position them as needed.<br />

And, finally, the slick part: indent the text –5000 pixels<br />

to the left of the heading’s position. This is<br />

important, because otherwise the heading’s text<br />

would still display above the rendered background<br />

image.<br />

Figure 2-7 shows the heading before, during, and after<br />

applying the CSS rule.<br />

So that takes care of the vertical text, which at first glance,<br />

may seem like the more challenging of the two replacement<br />

cases. However, the reality is that the second case—using a<br />

specific typeface for text that must remain editable—is<br />

actually more of a challenge, as you’ll see next.<br />

Figure 2-7. The heading in its default state (left), after the<br />

background image is applied (middle), and after setting<br />

text-indent:-5000px; (right)<br />

chapter 2 Taming a Wild CMS with CSS, Flash, and JavaScript<br />

41

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

Saved successfully!

Ooh no, something went wrong!