Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM Style perspective Property

Style perspective Property

Style Object Reference The Style object

Example

Set the perspective from which the element is viewed:

document.getElementById("myDIV").style.perspective="50px";

Try it »


Definition and Usage

The perspective property defines the distance, in pixels, between a 3D element and the view. This property allows you to change the perspective from which a 3D element is viewed.

When the perspective property is defined for an element, its child elements gain a perspective effect, not the element itself.

**Note:** The perspective property only affects 3D transformed elements!

**Tip:** Use this property together with the perspectiveOrigin property, so that you can change the bottom position of a 3D element.


Browser support

Internet Explorer Firefox Opera Google Chrome Safari

IE10+ and Firefox support the perspective property.

Chrome, Safari, and Opera support an alternative property, the WebkitPerspective property.


Syntax

Return the perspective property:

object

.style.perspective

Set the perspective property:

object

.style.perspective="

length

|none"

Attribute values

Value Description
length The distance between the element and the view, in pixels.
none Default. Same as 0. No perspective is applied.
initial Sets this property to its default value. See initial.
inherit Inherits this property from its parent element. See inherit.

Technical Details

Default value: none
Return Value: A string representing the element's perspective property.
CSS version CSS3

Related Articles

JavaScript Style object:perspectiveOrigin property

CSS Reference Manual:perspective property


Style Object Reference The Style object