perspective property: Explained

Subscribe to my newsletter and never miss my upcoming articles

Hey, this is the second post on the property of CSS. After the inline-size property we're now heading towards perspective property.

What is perspective property? (Basics)

-> The perspective property is used to give a 3D-positioned element some perspective. When defining the perspective property, child element gets perspective, not the parent element. So, the value defines how close the child is from the Z plane.

The syntax is simple.

 perspective: ; /*  length or none */

Learn about values

  • length: It is for how far is the element is placed from the view. It's used to apply a perspective transform to the element and its content.

  • none: You need definition of this also? If yes. Then it's none 😂 (no perspective transform will be applied.)


perspective property doesn't work in IE9 👊

-> If you run the pen you'll see how perspective works and what it is really. This is just basics and must know.

Now see this DEMO/Examples

  • Above you can see that the property is applied to the parent, that is -> perspective: 50em;
  • Below you can see that the perspective property is applied from the transform directly on children

Here in the above example you saw the difference between function and property.

What did you learn from?

  • Basics Of CSS property -> perspective
  • Making objects with perspective
  • Difference between function and property
  • Setting the property on the parent makes all children share the same 3D-space

-> Try to make a DICE using the perspective property (EASY)
-> A simple skyscraper (TOUGH)


No Comments Yet