CSSPositionValue

You’re reading the English version of this content since no translation exists yet for this locale. Help us translate this article!

This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The CSSPositionValue interface of the the CSS Typed Object Model API represents values for properties that take a position, for example object-position.

Constructor

CSSPositionValue.CSSPositionValue()
Creates a new CSSPositionValue object.

Properties

CSSPositionValue.x
Returns the item's position along the web page's horizontal axis.
CSSPositionValue.y
Returns the item's position along the vertical axis.

Methods

None.

Examples

The following example positions a container <div> 5 pixels from the top and 10 pixels from the left of the page. 

let replacedEl = document.getElementById( 'image' );
let position = new CSSPositionValue( CSS.px(35), CSS.px(40) );

replacedEl.attributeStyleMap.set( 'object-position', position ); 
console.log( position.x.value, position.y.value ); 
console.log( replacedEl.computedStyleMap().get('object-position') );

We set the object-position property, then check the values returned.

Specifications

Specification Status Comment
CSS Typed OM Level 1
The definition of 'CSSPositionValue' in that specification.
Working Draft Initial definition.

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
CSSPositionValue
Experimental
Chrome Full support 66Edge No support NoFirefox No support NoIE No support NoOpera Full support 53Safari No support NoWebView Android Full support 66Chrome Android Full support 66Firefox Android No support NoOpera Android Full support 47Safari iOS No support NoSamsung Internet Android ?
CSSPositionValue()
Experimental
Chrome Full support 66Edge No support NoFirefox No support NoIE No support NoOpera Full support 53Safari No support NoWebView Android Full support 66Chrome Android Full support 66Firefox Android No support NoOpera Android Full support 47Safari iOS No support NoSamsung Internet Android ?
x
Experimental
Chrome Full support 66Edge No support NoFirefox No support NoIE No support NoOpera Full support 53Safari No support NoWebView Android Full support 66Chrome Android Full support 66Firefox Android No support NoOpera Android Full support 47Safari iOS No support NoSamsung Internet Android ?
y
Experimental
Chrome Full support 66Edge No support NoFirefox No support NoIE No support NoOpera Full support 53Safari No support NoWebView Android Full support 66Chrome Android Full support 66Firefox Android No support NoOpera Android Full support 47Safari iOS No support NoSamsung Internet Android ?

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
Experimental. Expect behavior to change in the future.
Experimental. Expect behavior to change in the future.

See Also