过时
This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.
CSSPositionValue
接口的
CSS Typed Object Model API
represents values for properties that take a position, for example
object-position
.
CSSPositionValue.CSSPositionValue()
CSSPositionValue
对象。
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.
None.
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.
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
CSSPositionValue
|
Chrome 66 | Edge 79 | Firefox No | IE No | Opera 53 | Safari No | WebView Android 66 | Chrome Android 66 | Firefox Android No | Opera Android 47 | Safari iOS No | Samsung Internet Android 9.0 |
CSSPositionValue()
构造函数
|
Chrome 66 | Edge 79 | Firefox No | IE No | Opera 53 | Safari No | WebView Android 66 | Chrome Android 66 | Firefox Android No | Opera Android 47 | Safari iOS No | Samsung Internet Android 9.0 |
x
|
Chrome 66 | Edge 79 | Firefox No | IE No | Opera 53 | Safari No | WebView Android 66 | Chrome Android 66 | Firefox Android No | Opera Android 47 | Safari iOS No | Samsung Internet Android 9.0 |
y
|
Chrome 66 | Edge 79 | Firefox No | IE No | Opera 53 | Safari No | WebView Android 66 | Chrome Android 66 | Firefox Android No | Opera Android 47 | Safari iOS No | Samsung Internet Android 9.0 |
完整支持
不支持
实验。期望将来行为有所改变。
CSSImageValue
CSSKeywordValue
CSSNumericValue
CSSTransformValue
CSSUnparsedValue