Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

backgroundPosition property

Specifies the position of the background of the object.

CSS Backgrounds and Borders Module Level 3, Section 3.6CSS 2.1, Section 5.3.6

Syntax

Integer value = object.put_backgroundPosition( v);Integer value = object.get_backgroundPosition(* sPosition);

Property values

Type: BSTR

One or two of the values listed in Possible Values.

length

Floating-point number, followed by a supported length unit.

percentage

Integer, followed by a percent sign (%). The value is a percentage of the width or height of the object.

ValueMeaning
0% 0%

 

vAlignment

Vertical alignment value.

ValueMeaning
top

Vertical alignment is at the top.

center

Vertical alignment is centered.

bottom

Vertical alignment is at the bottom.

 

hAlignment

Horizontal alignment value.

ValueMeaning
left

Horizontal alignment is to the left.

center

Horizontal alignment is centered.

right

Horizontal alignment is to the right.

 

String format

[ [ percentage | length | left | center | right ] [ percentage | length | top | center | bottom ]? ] | [ [ left | center | right ] || [ top | center | bottom ] ]

CSS information

Applies ToAll elements
Mediavisual
Inheritedno
Initial Value0% 0%

Standards information

Remarks

If only one value is set, that value applies to the horizontal coordinate, and the vertical is set to "50%". If both values are set, the first value applies to the horizontal coordinate and the second value applies to the vertical.

Setting the values to "0% 0%" (initial value) positions the IHTMLStyle::backgroundImage to the upper left corner of the element's content block, which includes the padding.

Setting the background position using pixels positions the upper-left of the image at the specified x and y coordinates within the parent element. As the coordinates increase, the image moves to the right and down the visible area. By contrast, setting the background position with percentages uses a corresponding point on the image. At a position of "50% 50%" the image is effectively centered within the visible area.

This property can be set with the other background properties using the IHTMLStyle::background composite property.

Starting in Windows Internet Explorer 9, the background of an element can have multiple layers. The number of layers is determined by the number of comma-separated values in the IHTMLStyle::backgroundImage property. Each of the images is sized, positioned, and tiled according to the corresponding value in the other background properties (IHTMLStyle::backgroundAttachment, IHTMLCSSStyleDeclaration::backgroundClip, IHTMLCSSStyleDeclaration::backgroundOrigin, IHTMLStyle::backgroundPosition, IHTMLStyle::backgroundRepeat, and IHTMLCSSStyleDeclaration::backgroundSize). The first image in the list is the layer closest to the user, the next one is painted behind the first, and so on.

Requirements

Minimum supported client

Windows XP [desktop apps only]

Minimum supported server

Windows Server 2003 [desktop apps only]

Header

Mshtml.h

IDL

Mshtml.idl

DLL

Mshtml.dll

 

 

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.