Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS transforms: rotate vs rotateZ

I want to know which are the differences between the css transforms functions rotate and rotateZ:

If I applied those properties (with same values) to two different elements I get the same results:

HTML

<div class="rotateZ">
  <img src="http://ohdoylerules.com/content/images/css3.svg"/>
  <h3>RotateZ</h3>
</div>

<div class="rotate">
  <img src="http://ohdoylerules.com/content/images/css3.svg"/>
  <h3>Rotate</h3>
</div>

CSS

.rotateZ {
  transform: rotateZ(180deg);
}

.rotate {
  transform: rotate(180deg);
}
like image 936
ianaya89 Avatar asked Jul 15 '15 23:07

ianaya89


People also ask

What is rotateZ?

The rotateZ() CSS function defines a transformation that rotates an element around the z-axis without deforming it. Its result is a <transform-function> data type.

How do you rotate and translate in CSS?

transformation: translate(0,10%) rotate(25deg); The rotate operation is done first, then the translate . Show activity on this post. There is no need for that, as you can use css 'writing-mode' with values 'vertical-lr' or 'vertical-rl' as desired.


1 Answers

They do the exact same thing. rotateZ means 'rotate about the Z axis', and the Z axis points outwards from your screen, basically giving it a third dimension.

You use the same z-axis when you define a property called the z-index, which I'm sure you know about.

Source: http://www.w3.org/TR/css3-transforms/#funcdef-rotatez

like image 51
Lansana Camara Avatar answered Oct 22 '22 06:10

Lansana Camara