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.

68<br />

Part IV: Scripting and (X)<strong>HTML</strong><br />

Figure 16-3: After you visit a page, the link text<br />

color shows that the page was visited.<br />

Adding this type of navigation to your site couldn’t be simpler:<br />

1. Within the tags, add the preceding code (from Listing 16-1)<br />

inside and including the and tags.<br />

2. Add links inside individual tags.<br />

3. Make sure that the entire menu is inside a tag with an id attribute<br />

of navbar.<br />

If you add the <strong>CSS</strong> to your site via a link to a site-wide external style sheet<br />

(see Chapters 9 and 10 for more information on style sheets), you can add,<br />

change, or delete menu-bar links on your site at any time without having to<br />

touch a single line of <strong>CSS</strong> or JavaScript. You simply add or modify your tags. Slick, huh?<br />

Image rollovers with <strong>CSS</strong><br />

With text rollovers under your belt, kick things up a notch and move on<br />

to image rollovers. Say you have a basic image that you want to change to<br />

some different image when a visitor to your Web site rolls over its display<br />

frame. In the past, you needed JavaScript to handle the mechanics for<br />

image rollovers. Lucky for you, this can all easily be done with <strong>CSS</strong> now.<br />

Check out this sample page where you can mess with Jeff’s head (literally)<br />

www.dummieshtml.com/examples/ch16/image%20rollover.<br />

Here, we use some <strong>CSS</strong> trickery to apparently take one image and replace it<br />

with another. Actually, it’s really a single image that was created by stacking<br />

two separate images together, one next to the other. We use some format<br />

tricks to handle the rollover behavior using <strong>CSS</strong> by shifting our frame of reference<br />

to the right as we hover over that image.<br />

Figure 16-4 shows the sample image (notice how it’s really two images).<br />

Figure 16-5 shows the Web page of the formatted image with part of the<br />

image hidden from view. Hovering the cursor over the black-and-white part<br />

of the image, as shown in Figure 16-6, causes the rolled-over version of the

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

Saved successfully!

Ooh no, something went wrong!