Color and Background Properties

Background Position

 
 

Color and Background Properties

Color
Background Color
Background Image
Background Repeat
Background Attachment
Background Position
Background

Appearance:

background-position: <value>

Possible Values:

[<percentage> | <length>]{1,2} | [top | center | bottom] || [left | center | right]

Initial Value:

0% 0%

Applies to:

Block-level and replaced elements

Inherited:

No

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:


· Horizontal keywords (left, center, right)

· Vertical keywords (top, center, bottom)

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:

· top left = left top = 0% 0%

· top = top center = center top = 50% 0%

· right top = top right = 100% 0%

· left = left center = center left = 0% 50%

· center = center center = 50% 50%

· right = right center = center right = 100% 50%

· bottom left = left bottom = 0% 100%

· bottom = bottom center = center bottom = 50% 100%

· bottom right = right bottom = 100% 100%

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.

 

BreBru.Com Extra Information Techonology HTML