Changing the BackgroundThe background refers not to the background of the entire page, but to the background of a particular element. In other words, you can change the background of any elementincluding images, form elements, and tables. To use a background image:
Figure 11.5. First, we apply a background image to the outermost division, the wrap div. Then we position the image in the left, top corner of the wrap div and repeat it in both directions.
To repeat a background image: Type background-repeat: direction, where direction is either repeat (to tile the image both horizontally and vertically), repeat-x (to tile the image horizontally), repeat-y (to tile the image vertically), or no-repeat (to not tile the image at all) (Figure 11.5). To control whether the background image is attached or not:
To specify the position of an element's background image: Type background-position: x y, where x and y can be expressed as a percentage or as an absolute distance. Or use values of left, center, or right for x and top, center, or bottom for y (Figure 11.5). To change the background color:
Figure 11.8. The background for the screen div will make the text legible. Its color is temporary. Next, we add a background to links when they're hovered over, in order to make it clear that they really are links. Finally, we'll add a background color to the monthly opinion column in the sidebar div.
Figure 11.9. The screen div's background completely covers our new background image from the preceding page. We'll remedy that shortly (with padding, on page 177). Notice how the links that are not being hovered over share the same background as the screen, while the hovered resources link has a higher contrast background to show it off.
Figure 11.10. The background color for the sidebar is the lightest shade of blue I could manage. Just enough to set it off.
To change all the background properties at once:
Tips
|