设置过渡效果需要多少秒或毫秒才能完成。
javascriptobject oriented programmingfront end technology更新于 2024/6/25 21:00:17
要设置效果完成的持续时间,请使用 JavaScript 中的 transitionDuration 属性。
示例
您可以尝试运行以下代码来返回过渡效果需要多少秒或毫秒才能完成 −
<!DOCTYPE html>
<html>
<head>
<style>
#div1 {
position: relative;
margin: 10px;
height: 300px;
width: 400px;
padding: 20px;
border: 2px solid blue;
}
#div2 {
padding: 80px;
position: absolute;
border: 2px solid BLUE;
background-color: yellow;
transform: rotateY(45deg);
transition: all 5s;
}
#div2:hover {
background-color: orange;
width: 50px;
height: 50px;
padding: 100px;
border-radius: 50px;
}
</style>
</head>
<body>
<p>Hover over DIV2</p>
<button onclick = "display()">Set</button>
<div id = "div1">DIV1
<div id = "div2">DIV2</div>
</div>
<script>
function display() {
document.getElementById("myDIV").style.transitionDuration = "5s";
}
</script>
</body>
</html>
相关文章
有用资源
javascript 参考教程 - 该教程包含有关 javascript 的更多信息:https://www.cainiaomax.com/javascript/

