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.

Background<br />

Next, we apply the main background image (Figure 1-6) to the element. Although much larger than ideal, the JPG<br />

image will work as a tile. I would have preferred to use the GIF format for background images, but the level of detail and<br />

image gradation used for this large background image demanded the greater flexibility of the JPG format.<br />

Figure 1-6. The main background image, which will be placed in the center and tiled horizontally<br />

We use background shorthand in the CSS to place the tile in the center, at the top, and ensure it tiles only horizontally. Looking<br />

at the CSS for the body selector, you’ll see that alongside the main font rules and other items, all rules for background<br />

are combined using CSS shorthand, with the order background-color, background-image, background-position, background-attachment,<br />

and background-repeat.<br />

body {<br />

margin: 0;<br />

padding: 0;<br />

font-size: 95%;<br />

font-family: Georgia,'Lucida Grande',Verdana,sans-serif;<br />

text-align:center;<br />

color: #333;<br />

background: #C6C2B6 url(images/background.jpg) center top fixed repeat-x;<br />

}<br />

As the image is repeating horizontally (repeat-x), this takes up the whole width of the site, no matter how wide the browser<br />

window is. However, the page background-color is sampled on the flat color at the base of the background tile. The image<br />

combined with this color will complete the whole background and give the impression of a much taller background image.<br />

Within the shorthand, we used background-attachment:fixed to prevent the background from scrolling with the rest of the<br />

page, and background-position:center top to make sure that the midpoint of the first background image tile appears in<br />

line with the midpoint of the browser’s window. All other tiles needed to fill the width will be placed left and right of this<br />

initial centered image.<br />

chapter 1 Semantic Structure, Dirty Pretty Presentation<br />

11

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

Saved successfully!

Ooh no, something went wrong!