Fixing and Scrolling Background ImagesYou can have your background image fixed to the browser's viewport, or allow it to scroll along with the document by using the background-attachment property along with a value of either fixed or scroll. Typically, this is used for either the entire body or content areas within the document. However, as you've seen so far, you can use it in any element where it makes sense to do so. Consider the following rule:
body {background-image: url(arrows.gif); background-position: right; background-repeat:
Figure 8-11. When a background graphic is set to scroll, it scrolls along with the element to which it's attachedin this case, the body.
Figure 8-12. No matter where I scroll, the background image remains fixed in this case.
NOTE Some accessibility advisors suggest that using scrolling text over backgrounds is more difficult to see. I know this much: I get motion sensitivity fairly easily, and if I'm trying to scroll through text over a textured background, it will make me a little woozy. So use this technique with care! |