12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- <style>
- #div1 {
- width: 200px;
- height: 200px;
- background: red;
- transition: width 2s linear 2s;
- /*
- transition-property 规定过渡效果所针对的 CSS 属性的名称。
- transition-duration 规定过渡效果要持续多少秒或毫秒。
- transition-timing-function 规定过渡效果的速度曲线。
- transition-delay 规定过渡效果的延迟(以秒计)。
- linear 规定以相同速度开始至结束的过渡效果(等于 cubic-bezier(0,0,1,1))。
- ease 规定慢速开始,然后变快,然后慢速结束的过渡效果(cubic-bezier(0.25,0.1,0.25,1))。
- ease-in 规定以慢速开始的过渡效果(等于 cubic-bezier(0.42,0,1,1))。
- ease-out 规定以慢速结束的过渡效果(等于 cubic-bezier(0,0,0.58,1))。
- ease-in-out 规定以慢速开始和结束的过渡效果(等于 cubic-bezier(0.42,0,0.58,1))。
- */
- }
- </style>
- </head>
- <body>
- <div id="div1"></div>
- <button id="btn">按钮</button>
- <script>
- var btn = document.getElementById('btn')
- var div1 = document.getElementById('div1')
- btn.onclick = function () {
- div1.style.width = div1.offsetWidth + 500 + 'px'
- }
- </script>
- </body>
- </html>
|