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.

For the purposes of building on the proof-of-concept stage and doing a like-for-like translation, I am going to show how you<br />

do this using a combination of CSS background images and real text, rather than using img elements.<br />

Important: The downside of this approach, I should warn you, is that when (or if) you scale text up on the page, the background<br />

image for the button will not scale accordingly, and text may break out of the button area, as shown in Figure 8-11.<br />

Writing out an img element gets around that problem, but I’ll leave that to you to experiment with (it’s really not a stretch<br />

to adapt the script to do this, honest!).<br />

Styling the print links<br />

Figure 8-11. The effect of scaling up to maximum size in Internet<br />

Explorer when text sits on top of a button<br />

Regardless of the approach taken for the links, you’ll need to apply some CSS. In the proof of concept, I used a paragraph,<br />

which contained the two links. This can be used to include a background image (the gray section in the images in<br />

Figure 8-10 that includes a printer), while the links themselves need the backgrounds. Figure 8-12 shows the constituent<br />

parts.<br />

Figure 8-12. The background image and button used to style the print links<br />

Before looking at the CSS, just to recap: the HTML for these buttons (once generated via the JavaScript and inserted into the<br />

DOM) is exactly as per the proof of concept. The bold markup shown here is the part that will be dynamically generated:<br />

<br />

<br />

print this section<br />

print whole page<br />

<br />

<br />

<br />

chapter 8 Print Magic: Using the DOM and CSS to Save the Planet<br />

203

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

Saved successfully!

Ooh no, something went wrong!