CSS transform: rotate()

The CSS rotate() function is used to define the transform property, to rotate an element on the plane surface. For example:

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

   <div class="b"></div>

   <div class="c"></div>

   <div class="d"></div>

   <div class="e"></div>

   <div class="f"></div>

   <div class="g"></div>

Without rotate()







The default rotation is clockwise, whereas giving negative values (degrees) will rotate an element anti or counter clockwise.

Note - The rotate() function does similar job as of rotateZ().

CSS rotate() Syntax

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

transform: rotate(degree);

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

  • deg - Stands for degree. One full circle is equal to 360deg
  • grad - Stands for gradians. One full circle is equal to 400grad
  • rad - Stands for Radians. One full circle is equal to 6.2832rad
  • turn - Stands for turns. One full circle is equal to 1turn

CSS Online Test

« Previous Tutorial Next Tutorial »

Follow/Like Us on Facebook

Subscribe Us on YouTube