HTML and CSS Reference
In-Depth Information
In most situations, it is suggested you set a background color even if it
will be covered by a background image. A slow or bad connection can
sometimes mean an image doesn't load or content can become too large for the
area covered by a nontiling image. Choose a background color that is sampled
from the image or pattern used to maintain the desired readability and visual
contrast between the content and the background.
background-repeat
The tiling of background images is set with the
background-repeat
property. The following keywords are the most commonly used values:
■
repeat
: The image tiles in both directions (default).
■
repeat-x
: The image tiles in the horizontal direction.
■
repeat-y
: The image tiles in the vertical direction.
■
no-repeat
: The image does not repeat.
background-attachment
The
background-attachment
property defines how a background posi-
tion is determined.
■
scroll
: The background is fixed with respect to the specific element
and scrolls along with it in the document. (This is the default.)
■
fixed
: The background is fixed with respect to the viewport and does
not scroll with the element; it appears only when that element is
“over” its position in the viewport.
background-position
The
background-position
property specifies the position of the back-
ground image (or the positioning of the first
background-image
tile when
repeating) given as a set of two values: horizontal and then vertical.