编辑下面的代码:【加编码】
<html> <head> <style> #myDIV { border:1px solid black; background-color:lightblue; width:270px; height:200px; overflow:auto; transition:all 5s; -webkit-transition:all 5s; /* 针对 Safari */ } #myDIV:hover { background-color:coral; width:570px; height:500px; padding:100px; border-radius:50px; } </style> </head> <body> <p>把鼠标指针悬停在 DIV 元素上,它将改变颜色和尺寸大小!</p> <p>点击“尝试一下”按钮,再次把鼠标指针悬停在 DIV 元素上。改变将进行得更快一些!</p> <button onclick="myFunction()">尝试一下</button> <div id="myDIV"> <h1>myDIV</h1> </div> <script> function myFunction() { document.getElementById("myDIV").style.transitionDuration = "1s"; document.getElementById("myDIV").style.WebkitTransitionDuration = "1s"; } </script> <p>Internet Explorer 10、Firefox、Opera 和 Chrome 支持 transitionDuration 属性。</p> <p>Safari 支持另一个可替代该属性的属性,即 WebkitTransitionDuration 属性。</p> </body> </html>
结果: 【此窗口】 帮助?
Try it Yourself - © 自强学堂