How to apply a 2D or 3D transformation to an element with CSS



Apply a 2D or 3D transformation to an element with the transform property in CSS. You can try to run the following code to rotate an element using transformation

Example

Live Demo

<!DOCTYPE html>
<html>
   <head>
      <style>
         div {
            width: 200px;
            height: 100px;
            background-color: gray;
            transform: rotate(10deg);
         }
      </style>
   </head>
   <body>
      <h1>Rotation</h1>
     <div>Demo</div>
   </body>
</html>

Advertisements