Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

translate vs transform-origin css3

Tags:

css

transform

I was wondering if someone could help me. I've been having trouble understanding what exactly is the css3 property: transform-origin. I can't seem to follow the direction it is moving.

So for example, lets say you have a square div, and you rotate it 40 degrees. and then you perform a transform-origin: 100% 0%. can't you just do a translateX(and some value)? It seems like translateX will move it along the x-axis with respect to the newly rotated axis after performing a rotate. I can't seem to follow what transform-origin is doing, or what exactly it even is.

A clear and thorough example would be much appreciated. =)

like image 742
Sasha Avatar asked Dec 25 '11 02:12

Sasha


People also ask

Does transform origin affect translate?

transform-origin changes the point at which the element transforms rather than moving the entire element (as translate would). The default value is transform-origin: 50% 50%; .

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.

What does transform translate do CSS?

The transform CSS property lets you rotate, scale, skew, or translate an element. It modifies the coordinate space of the CSS visual formatting model.

What is the default transform origin?

By default, the origin of a transform is “50% 50%”, which is exactly in the center of any given element. Changing the origin to “top left” (as in the demo above) causes the element to use the top left corner of the element as a rotation point.


1 Answers

transform-origin changes the point at which the element transforms rather than moving the entire element (as translate would). The default value is transform-origin: 50% 50%;.

Here is an illustration: http://jsfiddle.net/joshnh/73g7t/

like image 116
joshnh Avatar answered Sep 29 '22 15:09

joshnh