CSS transform: rotateZ()

The CSS rotateZ() function is used to define the transform property, to rotate an element along z-axis, in this way:

css rotateZ example

For example:

HTML with CSS Code
<!DOCTYPE html>
<html>
<head>
   <style>
      div{width: 120px; height: 60px; background: peru; margin: auto;}
      .b{transform: rotateZ(12deg);}
      .c{transform: rotateZ(25deg);}
      .d{transform: rotateZ(45deg);}
      .e{transform: rotateZ(80deg);}
      .f{transform: rotateZ(90deg);}
      .g{transform: rotateZ(135deg);}
      .h{transform: rotateZ(180deg);}
   </style>
</head>
<body>
   
   <h2>Without rotateZ()</h2>
   <div class="a"></div>

   <h2>rotateZ(12deg)</h2>
   <div class="b"></div>

   <h2>rotateZ(25deg)</h2>
   <div class="c"></div>

   <h2>rotateZ(45deg)</h2>
   <div class="d"></div>

   <h2>rotateZ(80deg)</h2>
   <div class="e"></div>

   <h2>rotateZ(90deg)</h2>
   <div class="f"></div>

   <h2>rotateZ(135deg)</h2>
   <div class="g"></div>

   <h2>rotateZ(180deg)</h2>
   <div class="h"></div>
   
</body>
</html>
Output

Without rotateZ()

rotateZ(12deg)

rotateZ(25deg)

rotateZ(45deg)

rotateZ(80deg)

rotateZ(90deg)

rotateZ(135deg)

rotateZ(180deg)

CSS rotateZ() Syntax

The syntax of rotateZ() function in CSS, is:

transform: rotateZ(degree);

The value of degree parameter will be any of the following:

CSS Online Test


« Previous Tutorial Next Tutorial »


Liked this post? Share it!