12.transition.html 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Document</title>
  7. <style>
  8. #box {
  9. width: 200px;
  10. height: 200px;
  11. background: #00f;
  12. transition: height 5s linear 1s;
  13. }
  14. </style>
  15. </head>
  16. <body>
  17. <!--
  18. transition:在一定的时间内平滑的过渡
  19. transition-property: 要参与过度的属性 (all/width/height)
  20. transition-duration: 动画持续效果的时间
  21. transition-timing-function: 动画执行的方式
  22. ease - 规定过渡效果,先缓慢地开始,然后加速,然后缓慢地结束(默认)
  23. linear - 规定从开始到结束具有相同速度的过渡效果
  24. ease-in -规定缓慢开始的过渡效果
  25. ease-out - 规定缓慢结束的过渡效果
  26. ease-in-out - 规定开始和结束较慢的过渡效果
  27. cubic-bezier(n,n,n,n) - 允许您在三次贝塞尔函数中定义自己的值
  28. transition-delay: 执行效果延迟的时间
  29. -->
  30. <div id="box"></div>
  31. <script>
  32. var box = document.getElementById("box");
  33. box.onclick = function () {
  34. box.style.width = 500 + 'px';
  35. box.style.height = 500 + 'px';
  36. }
  37. </script>
  38. </body>
  39. </html>