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

CSS3 perspective property

CSS3 perspective property

Example

Set the angle from which an element is viewed:

div

{

perspective:

500

px

; -

webkit-perspective:

500

px

;

/*

Safari and Chrome

*/

}

Try it »


Browser support

The numbers in the table indicate the first browser version that supports this property.

A number immediately before -webkit-, -ms-, or -moz- indicates the first browser version that supports that prefixed property.

property
perspective 36.0
12.0 -webkit- 10.0 16.0
10.0 -moz- 9.0
4.0.3 -webkit- 23.0
15.0 -webkit-

Property definition and usage

How many pixels a 3D element is viewed from is defined by the perspective property. This property allows you to change how a 3D element is viewed in perspective.

When defining the perspective property, it is the perspective of an element's children, not the element itself.

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

Tip: Use this property together with the perspective-origin property, so that you can change the base position of a 3D element.

Default value: none
Inherited: no
Version: CSS3
JavaScript syntax: object.style.perspective=500

Syntax

perspective:

number

|none;

Value Description
number The distance between the element and the view, in pixels.
none Default. Same as 0. No perspective is applied.