In our CSS lessons, we have learned 5 properties to set background color and background images. This page is a brief summary of those properties.
The properties we have discussed are:
This sample stylesheet uses the color property and all of the background properties to set the basic appearance of a web page. This example would produce black text on a white page with a small image centered on a page that would stay in the middle of a pc monitor screen when the viewer scrolls the page.
/* basic page appearance */
body {
color: #000000;
background-color: #ffffff;
background-image: url(../images/mallrat.gif);
background-repeat: no-repeat;
background-attachment: fixed;
background-position: center;
There is a shorthand version for all of the background properties together. You may use the single background property if if you feel confident using all of the background properties. and you are sure you can remember the correct order for the values. Personally, I would prefer to declare the 5 properties individually to make sure I don't mess up.
The form for the shorthand background declaration is:
background: value1 value2 value3 value4 value5;
Notice that there are no semi-colons between the 5 values. The order for the 5 values is:
body {
background:
#00ff00
url(../images/mallrat.gif)
no-repeat
fixed
center;
}
There is no assignment for this lesson. Call someone you love, read some poetry or write a letter.
Happy coding!
Gnubee