22.04.2013 Views

HTML, XHTML & CSS

HTML, XHTML & CSS

HTML, XHTML & CSS

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

34<br />

Part V: The Future of (X)<strong>HTML</strong><br />

Backgrounds<br />

Lining up multiple elements so that their backgrounds align perfectly<br />

and, likewise, mixing and matching multiple backgrounds can be difficult<br />

to achieve. It might take many lines of markup to get this job done right,<br />

especially working with <strong>CSS</strong>1 or <strong>CSS</strong>2. However, with <strong>CSS</strong>3, you can apply<br />

multiple backgrounds to a single element easily, and then use it to provide<br />

a backdrop for an element or a group of subsidiary elements. For example,<br />

on the backgrounds example page at www.dummieshtml.com/examples/<br />

ch20/backgrounds/index.html, we combine three background images<br />

and apply them to one div.<br />

The relevant <strong>CSS</strong>3 markup looks like this:<br />

.customBackground {<br />

margin: 0px auto;<br />

width: 400px;<br />

height: 200px;<br />

border-radius: 10px;<br />

background:<br />

url(images/top.gif) top left repeat-x,<br />

url(images/bottom.gif) bottom left repeat-x,<br />

url(images/middle.gif) center repeat;<br />

}<br />

The trick to this markup lies in the background specification, where we reference<br />

URLs for images for the three different backgrounds named top.gif,<br />

bottom.gif, and middle.gif, respectively. We use the repeat-x attribute<br />

to repeat the top and bottom horizontally. Using repeat means that middle.<br />

gif is repeated both horizontally and vertically. Top.gif applies the dark to<br />

medium blue shading at the top of the frame, bottom.gif does likewise from<br />

the bottom, and middle.gif supplies the dots. See Figure 20-4; visit the page<br />

at www.dummieshtml.com/examples/ch20/backgrounds/index.html.<br />

<strong>CSS</strong>3.info strikes again in this case with its coverage of multiple backgrounds<br />

(particularly, check out its other background property coverage and excellent<br />

<strong>CSS</strong>3 coverage in general) at www.css3.info/preview/multiplebackgrounds.<br />

Shadows<br />

Shadows first appeared in <strong>CSS</strong>2, but they enjoyed only limited browser support<br />

and required various hacks to make them work properly. <strong>CSS</strong>3 lets<br />

designers apply and manage shadows for borders, images, and text in more<br />

or less the same way. Note that this is another case where some extensions<br />

are needed for the box shadow (around the div element) and image shadow

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

Saved successfully!

Ooh no, something went wrong!