MDN self-hosted library · e01.org

CSSTransformValue: is2D property

CSS Typed Object Model API

Open notebook · 1 cells web-api-instance-property upstream source

CSS Typed Object Model API

The is2D read-only property of the CSSTransformValue interface returns whether the transform is 2D or 3D.

is2D is true only if every CSSTransformComponent in the CSSTransformValue is itself 2D (see CSSTransformComponent.is2D), otherwise it is false.

Value

A boolean. true if every object in the value is 2D, otherwise false.

Examples

Comparing 2D and 3D transforms

const transform2D = new CSSTransformValue([
  new CSSTranslate(CSS.px(10), CSS.px(20)),
  new CSSScale(2, 3),
]);

console.log(transform2D.is2D); // true

const transform3D = new CSSTransformValue([
  new CSSTranslate(CSS.px(10), CSS.px(20), CSS.px(30)),
  new CSSScale(2, 3),
]);

console.log(transform3D.is2D); // false

Specifications

Browser compatibility

See also