HTML DOM Style transitionDelay 属性
htmldomweb developmentfront end technology更新于 2024/5/23 21:00:17
HTML DOM Style transitionDelay 属性返回并修改元素过渡效果开始的时间。
语法
以下是语法 −
1. 返回 transitionDelay
object.transitionDelay
2. 修改 transitionDelay
object.transitionDelay = “value”
此处,value 可以为 −
| Sr.No | Value & |
|---|---|
| 1 | initial 将此属性值设置为其默认值。 |
| 2 | inherit 从其父元素继承此属性值。 |
| 3 | time 表示过渡效果的延迟时间,以秒(s)或毫秒(ms)为单位。 |
让我们看一个 HTML DOM Style transitionDelay 属性的示例 −
示例
<!DOCTYPE html>
<html>
<style>
body {
color: #000;
height: 100vh;
}
.btn {
background: #db133a;
border: none;
height: 2rem;
border-radius: 2px;
width: 40%;
display: block;
color: #fff;
outline: none;
cursor: pointer;
margin: 1rem 0;
}
.circle {
height: 100px;
width: 100px;
background-color: #db133a;
}
.circle:hover {
height: 200px;
width: 200px;
border-radius: 50%;
transition: all 1s;
}
.show {
font-size: 1.2rem;
margin: 1rem 0;
}
</style>
<body>
<h1>DOM Style transitionDelay Property Demo</h1>
<div class='circle'></div>
<button onclick="set()" class="btn">Set TransitionDelay</button>
<div class="show">Now, hover on the square</div>
<script>
function set() {
document.querySelector('.circle').style.transitionDelay = "2s";
}
</script>
</body>
</html>
输出

点击"设置 TransitionDelay"按钮,然后将鼠标悬停在"红色"方块上即可查看 transitionDelay 效果。

相关文章
有用资源
html 参考教程 - 该教程包含有关 html 的更多信息:https://www.cainiaomax.com/html/

