Code has been added to clipboard!

CSS Perspective and Perspective-Origin Properties

Reading time 1 min
Published Aug 8, 2017
Updated Jan 21, 2020

CSS perspective explained

By using the CSS perspective property, you can specify the distance of a 3D element in pixels:

Example
div {
    -webkit-perspective: 60px; /* Opera, Safari, Chrome */
    perspective: 6000px;
}

Note: CSS perspective does not change the rendering of the element. For that, use transform: perspective().

The syntax for CSS perspective

The only value you need to define is the distance:

perspective: distance;

The default value is none, which means no CSS perspective transformations. You can set a custom value by using length units (e.g., pixels or ems).

Udacity
Pros
  • Simplistic design (no unnecessary information)
  • High-quality courses (even the free ones)
  • Variety of features
Main Features
  • Nanodegree programs
  • Suitable for enterprises
  • Paid certificates of completion
Coursera
Pros
  • Professional service
  • Flexible timetables
  • A variety of features to choose from
Main Features
  • Professional certificates of completion
  • University-level courses
  • Multiple Online degree programs
Datacamp
Pros
  • Great user experience
  • Offers quality content
  • Very transparent with their pricing
Main Features
  • Free certificates of completion
  • Focused on data science skills
  • Flexible learning timetable

Defining the CSS perspective origin

When you're using the perspective CSS property, the center of the element becomes its vanishing point by default. To define a custom point, you can also apply perspective-origin:

Example
div {
    -webkit-perspective: 250px; /* Opera, Chrome, Safari */
    -webkit-perspective-origin: 25% 25%; /* Opera, Chrome, Safari */
    perspective: 250px;
    perspective-origin: 25% 25%;  	
}

The syntax for this property is rather simple – you need to specify the position in relation to both horizontal and vertical axes:

perspective-origin: x-axis y-axis;

You can use use percentages or keywordsleft, center, or right for the horizontal and top, center, or bottom for the vertical value.

Note: CSS perspective-origin will not work without perspective.

Browser support

Browser image
Chrome
36+
Browser image
Edge
12+
Browser image
Firefox
16+
Browser image
IE
10+
Browser image
Opera
15+
Browser image
Safari
9+

Mobile browser support

Browser image
Chrome
36+
Browser image
Firefox
16+
Browser image
Opera
All
Browser image
Safari
9+

Latest Udacity Coupon Found:

Verified STAFF PICK

75% OFF COURSES

Udacity Black Friday Offer

The best time to save on Udacity courses is now - follow this coupon to access a 75% Udacity Black Friday discount & enjoy learning at a very low cost!

Expiration date: 27/01/2021
3176 People Used
Only 97 Left
Rating
5.0