Yogesh Chauhan's Blog

perspective property in CSS

in CSS on February 14, 2021

As per Vocabulary.com, perspective is the appearance of things relative to one another as determined by their distance from the viewer.

Using this perspective property, we can add some perspective to an element that are positioned in 3D. It determines the distance between the z=0 plane and the user or in other words, it determines how far the object is away from the user. So, a lower value will result in a more intensive 3D effect than a higher value.

When we define the perspective property for an element, the CHILD elements gets the perspective view.

Example

Few things to remember

  • If the value is 0 or a negative number, no perspective transform is applied.
  • Each 3D element with z>0 becomes larger; each 3D-element with z<0 becomes smaller.
  • The parts of the 3D elements that are behind the user — i.e. their z-axis coordinates are greater than the value of the perspective CSS property — are not drawn.
  • The vanishing point is by default placed at the center of the element, but its position can be changed using the perspective-origin property.

It’s supported by most modern browsers.

Credit: w3Schools and MDN


Most Read

#1 Solution to the error “Visual Studio Code can’t be opened because Apple cannot check it for malicious software” #2 How to add Read More Read Less Button using JavaScript? #3 How to check if radio button is checked or not using JavaScript? #4 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #5 PHP Login System using PDO Part 1: Create User Registration Page #6 How to uninstall Cocoapods from the Mac OS?

Recently Posted

#Apr 8 JSON.stringify() in JavaScript #Apr 7 Middleware in NextJS #Jan 17 4 advanced ways to search Colleague #Jan 16 Colleague UI Basics: The Search Area #Jan 16 Colleague UI Basics: The Context Area #Jan 16 Colleague UI Basics: Accessing the user interface
You might also like these
What is Zdog?MiscellaneousPre-defined DatePipe format options in Angular 9AngularWhat is IPS(Intrusion Prevention System), How Does It Work and What are the Detection Types?MiscellaneousReverse a String in JavaScriptJavaScriptFor Each Loop in Swift for BeginnersSwiftHow to disable the Recovery Mode in WordPress?WordPressColleague UI Basics: Accessing the user interfaceColleagueHow to add and remove capabilities from a role in WordPress?WordPressMiddleware in NextJSNextJSOptional arguments, Default parameters and REST parameters in JavaScriptJavaScriptThe unique operator($) in Envision BasicEnvision Basic$this Keyword in PHPPHP