A.5. BackgroundsCSS provides several properties for controlling the background of an element, including coloring the background, placing an image behind an element, and controlling how that background image is positioned. A.5.1. backgroundProvides a shorthand method of specifying properties that appear in the background of an element, like a color , an image, and the placement of that image. It combines the five background properties (described next ) into one compact line, so you can get the same effect with much less typing. However, if you don't set one of the properties, browsers use that property's normal value instead. For example, if you don't specify how a background image should repeat, browsers will tile that image from left to right and top to bottom (see Section 8.3).
A.5.2. background-attachmentSpecifies how a background image reacts when your visitor scrolls the page. The image either scrolls along with the rest of the content or remains in place. You can add a logo to the upper-left corner of a very long Web page, using the background-attachment property's fixed value, and make that image stay in the upper-left corner even when the page is scrolled. (In Internet Explorer 6 and earlier, this property works only for the <body> tag.)
A.5.3. background-colorAdds a color to the background of a style. The background sits underneath the border and underneath a background image, a fact to keep in mind if you use one of the non-solid border styles like dashed or dotted . In these cases, the background color shows through the gaps between the dashes or dots.
A.5.4. background-imagePlaces an image into the background of a style. Other page elements sit on top of the background image, so make sure that text is legible where it overlaps the image. You can always use padding to move content away from the image, too. The image tiles from left to right and top to bottom, unless you set the background-repeat property as well.
A.5.5. background-positionControls the placement of an image in the background of a page element. Unless you specify otherwise , an image begins in the element's top-left corner. If the image tiles, background-position controls the image's start point (see background-repeat next). If you position an image in the center of an element, the browser puts the image there, and then tiles the image up and to the left and down and to the right. In many cases, the exact placement of an image doesn't cause a visible difference in the background tiling, but it lets you make subtle changes to the positioning of a pattern in the background.
A.5.6. background-repeatControls whether, or how, a background image repeats. Normally, background images tile from the top left to the bottom right, filling the element's entire background.
|