The CSSTranslate()
constructor creates a new CSSTranslate
object representing the translate() value of the individual transform
property in CSS.
On this page
CSSTranslate: CSSTranslate() constructor
Syntax
js
new CSSTranslate(x, y)
new CSSTranslate(x, y, z)
Parameters
-
x
-
A value for the x-axis of the
CSSTranslate
object to be constructed. This must be a<length-percentage>
. -
y
-
A value for the y-axis of the
CSSTranslate
object to be constructed. This must be a<length-percentage>
. z
Optional-
A value for the z-axis of the
CSSTranslate
object to be constructed. This must be a<length>
.If a value is passed for the
z-axis
this is a 3d transform. The value ofis2D
will be set to false.
Exceptions
-
TypeError
-
Raised if the value of
CSSTranslate.x
orCSSTranslate.y
is not a<length-percentage>
. -
TypeError
-
Raised if the value of
CSSTranslate.z
exists but is not a<length>
.
Examples
To do
Specifications
Specification |
---|
CSS Typed OM Level 1 # dom-csstranslate-csstranslate |
Browser compatibility
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
CSSTranslate |
66 | 79 | No | No | 53 | 16.4 | 66 | 66 | No | 47 | 16.4 | 9.0 |
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/CSSTranslate/CSSTranslate