QP School
Advanced transitions in CSS3 - Printable Version

+- QP School (https://qomplainerzschool.lima-city.de)
+-- Forum: Tutorials (https://qomplainerzschool.lima-city.de/forumdisplay.php?fid=3)
+--- Forum: CSS3 Tutorials (https://qomplainerzschool.lima-city.de/forumdisplay.php?fid=5)
+--- Thread: Advanced transitions in CSS3 (/showthread.php?tid=5177)



Advanced transitions in CSS3 - Qomplainerz - 07-26-2023

Example:

<!DOCTYPE html>
<html>
<head>
  <title>Advanced Transitions Example</title>
  <style>
    /* Add a custom easing function to the transition */
    div {
      width: 100px;
      height: 100px;
      background-color: lightblue;
      transition: width 1s cubic-bezier(0.68, -0.55, 0.27, 1.55);
    }
    div:hover {
      width: 200px;
    }
  </style>
</head>
<body>
  <div>Hover over this div to see the transition effect.</div>
</body>
</html>

Explanation:

Advanced transitions can use custom easing functions (cubic-bezier) to control the animation's acceleration and deceleration. In this example, the div element grows its width from 100 pixels to 200 pixels smoothly over 1 second using a custom easing function.