11_transition.html 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>Document</title>
  8. <style>
  9. #div1 {
  10. width: 200px;
  11. height: 200px;
  12. background: red;
  13. transition: width 2s linear 2s;
  14. /*
  15. transition-property 规定过渡效果所针对的 CSS 属性的名称。
  16. transition-duration 规定过渡效果要持续多少秒或毫秒。
  17. transition-timing-function 规定过渡效果的速度曲线。
  18. transition-delay 规定过渡效果的延迟(以秒计)。
  19. linear 规定以相同速度开始至结束的过渡效果(等于 cubic-bezier(0,0,1,1))。
  20. ease 规定慢速开始,然后变快,然后慢速结束的过渡效果(cubic-bezier(0.25,0.1,0.25,1))。
  21. ease-in 规定以慢速开始的过渡效果(等于 cubic-bezier(0.42,0,1,1))。
  22. ease-out 规定以慢速结束的过渡效果(等于 cubic-bezier(0,0,0.58,1))。
  23. ease-in-out 规定以慢速开始和结束的过渡效果(等于 cubic-bezier(0.42,0,0.58,1))。
  24. */
  25. }
  26. </style>
  27. </head>
  28. <body>
  29. <div id="div1"></div>
  30. <button id="btn">按钮</button>
  31. <script>
  32. var btn = document.getElementById('btn')
  33. var div1 = document.getElementById('div1')
  34. btn.onclick = function () {
  35. div1.style.width = div1.offsetWidth + 500 + 'px'
  36. }
  37. </script>
  38. </body>
  39. </html>