<!DOCTYPE html>
<html>
<head>
<style>
#myDIV {
border: 1px solid black;
background-color: lightblue;
width: 270px;
height: 200px;
overflow: auto;
transition: all 2s;
}
#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.transitionTimingFunction = "linear";
}
</script>
</body>
</html>