Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the difference between perspective origin and transform origin in css

Tags:

css

As i understand it is probably how it looks is perspective, and how it actually moves around in its space is origin.

I am more clear on transform origin and not so much on perspective origin.

Could someone give me links or explanation what perspective it and how origin matters.

like image 671
Techsin Avatar asked Sep 10 '13 17:09

Techsin


People also ask

What does perspective origin do I CSS?

The perspective-origin CSS property determines the position at which the viewer is looking. It is used as the vanishing point by the perspective property.

What is perspective in transform in CSS?

The perspective() CSS function defines a transformation that sets the distance between the user and the z=0 plane, the perspective from which the viewer would be if the 2-dimensional interface were 3-dimensional. Its result is a <transform-function> data type.

What is CSS transform origin?

The transform origin is the point around which a transformation is applied. For example, the transform origin of the rotate() function is the center of rotation. In effect, this property wraps a pair of translations around the element's other transformations.

What is the use of transform origin?

Definition and Usage The transform-origin property allows you to change the position of transformed elements. 2D transformations can change the x- and y-axis of an element. 3D transformations can also change the z-axis of an element. To better understand the transform-origin property, view a demo.


1 Answers

perspective is used to set the view angle for a element's children.
perspective origin is the point in space from where you are looking at the element

transform is the simple coordinate thing which is used to rotate/translate object(element).
transform origin sets the point about which you are translating/rotating an object.

for an instance you want to rotate an div at 45 degrees about x-axis(horizontal axis).
you use transform:rotateX(45deg);
enter image description here

div will rotate but you still see a rectangle on screen as you are looking at it from z axis with no perspective.

but when you increase perspective, you will see the 3d view of the div.
enter image description here
the center of your eye is set by perspective-origin. default value is 50% 50% means center. increasing and decreasing x or y value will move your "eye" accordingly.
enter image description here

transform origin on the other hand sets the point of transform for example if you need to rotate an rectangle about any other point other than its center, the you will use transform-origin property
enter image description hereenter image description here

like image 133
rishabh goel Avatar answered Sep 28 '22 15:09

rishabh goel