Compiling in CSS
Compiling [background]
The property
background
is a short hand for all the background properties listed in this lesson.
With
background
you can compress several properties and thereby write your style sheet in a shorter way which makes it easier to read.
For example, look at these five lines:
background-color: #FFCC66;
background-image: url("butterfly.gif");
background-repeat: no-repeat;
background-attachment: fixed;
background-position: right bottom;
Using
background
the same result can be achieved in just one line of code:
background: #FFCC66 url("butterfly.gif") no-repeat fixed right bottom;
The list of order is as follows:
[background-color]
| [background-image]
| [background-repeat]
| [background-attachment]
| [background-position]
If a property is left out, it will automatically be set to its default value. For example, if
background-attachment
and background-position
are taken out of the example:
background: #FFCC66 url("butterfly.gif") no-repeat;
These two properties that are not specified would merely be set to their default values which as you know are scroll and top left.
Comments
Post a Comment