|
Background and Color Properties
Color
The color property allows authors to specify the color of an element. See the Units section for color value descriptions. Some example color rules include:
To help avoid conflicts with user style sheets, background and color properties should always be specified together. Background Color
The background-color property sets the background color of an element. For example:
To help avoid conflicts with user style sheets, background-image should be specified whenever background-color is used. In most cases, background-image: none is suitable. Authors may also use the shorthand background property, which is currently better supported than the background-color property. Background Image
The background-image property sets the background image of an element. For example:
When a background image is defined, a similar background color should also be defined for those not loading images. Authors may also use the shorthand background property, which is currently better supported than the background-image property. Background Repeat
The background-repeat property determines how a specified background image is repeated. The repeat-x value will repeat the image horizontally while the repeat-y value will repeat the image vertically. For example:
In the above example, the image will only be tiled horizontally. Authors may also use the shorthand background property, which is currently better supported than the background-repeat property. Background Attachment
The background-attachment property determines if a specified background image will scroll with the content or be fixed with regard to the canvas. For example, the following specifies a fixed background image:
Authors may also use the shorthand background property, which is currently better supported than the background-attachment property. Background Position
The background-position property gives the initial position of a specified background image. This property may only be applied to block-level elements and replaced elements. (A replaced element is one for which only the intrinsic dimensions are known; HTML replaced elements include IMG, INPUT, TEXTAREA, SELECT, and OBJECT.) The easiest way to assign a background position is with keywords:
Percentages and lengths may also be used to assign the position of the background image. Percentages are relative to the size of the element. Although lengths are allowed, they are not recommended due to their inherent weakness in dealing with differing display resolutions. When using percentages or lengths, the horizontal position is specified first, followed by the vertical position. A value such as 20% 65% specifies that the point 20% across and 65% down the image be placed at the point 20% across and 65% down the element. A value such as 5px 10px specifies that the upper left corner of the image be placed 5 pixels to the right of and 10 pixels below the upper left corner of the element. If only the horizontal value is given, the vertical position will be 50%. Combinations of lengths and percentages are allowed, as are negative positions. For example, 10% -2cm is permitted. However, percentages and lengths cannot be combined with keywords. The keywords are interpreted as follows:
If the background image is fixed with regard to the canvas, the image is placed relative to the canvas instead of the element. Authors may also use the shorthand background property, which is currently better supported than the background-position property. Background
The background property is a shorthand for the more specific background-related properties. Some examples of background declarations follow:
A value not specified will receive its initial value. For example, in the first three rules above, the background-position property will be set to 0% 0%. To help avoid conflicts with user style sheets, background and color properties should always be specified together. Maintained by John Pozadzides and Liam Quinn Copyright © 1997 John Pozadzides and Liam Quinn. All rights reserved. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
With any suggestions or questions please feel free to contact us |