How to work with CSS Transitions?

Use the transition property to work with CSS Transitions.

You can try to run the following code to implement transitions in CSS:

Example

Live Demo

<!DOCTYPE html>
<html>
   <head>
      <style>
         div {
            width: 150px;
            height: 150px;
            background: blue;
            transition: width 4s;
         }
         div:hover {
            width: 200px;
         }
      </style>
   </head>
   <body>
      <h1>Heading One</h1>
      <p>Hover over the below box to change its width.</p>
      <div></div>
   </body>
</html>
Updated on: 2020-06-23T16:27:52+05:30

103 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements