HTML and CSS Reference
In-Depth Information
FiGure 10-8
One final refinement you can toss into the mix comes with the
background-attachment
property.
Via
background-attachment
, you can set the image to scroll with the window (the default behav-
ior) or stay in its original fixed position. The two primary values for
background-attachment
are
scroll
and
fixed
.
CSS allows you to define these properties separately or as a group under the
background
property.
For example, this verbose code:
#header {
background-color: black;
background-image: url(“../images/header_bg.png”);
background-repeat: repeat-x;
background-position: left top;
background-attachment: scroll;
}
could be written much more succinctly:
#header {
background: black url(“..images/header_bg.png”) repeat-x left top scroll;
}
You can safely mix any number of background properties — you don't have to include them all.
Try iT
In this Try It you learn how to add a background image to the page.