How to create a transition effect with CSS?



To create a transition effect, set the property for the transition effect. With that also set the duration of effect.

transition: height 5s;

You can try to run the following code to create a transition effect

Example

Live demo

<!DOCTYPE html>
<html>
   <head>
      <style>
         div {
            width: 150px;
            height: 150px;
            background: blue;
            transition: width 3s;
         }
         div:hover {
            width: 250px;
         }
      </style>
   </head>
   <body>
      <h1>Heading One</h1>
      <p>Hover over the below box to change its width.</p>
      <div></div>
   </body>
</html>

Advertisements