如何用JavaScript设置过渡效果的速度曲线?
使用transitionTimingFunction 属性设置过渡的速度。将其设置为以下任意值-缓动,缓入,缓动,线性等。
示例
您可以尝试运行以下代码以使用JavaScript返回过渡效果的速度曲线-
<!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("div2").style.transitionTimingFunction =
"ease-in";
}
</script>
</body>
</html>热门推荐
4 留学生祝福语简短
10 培训机构升班祝福语简短
11 元旦祝福语 简短独特群发
12 新郎朋友祝福语简短大气
13 新年祝福语大全简短感谢
14 姐妹订婚刺绣祝福语简短
15 同事生日祝福语简短独特
16 惊喜自己的祝福语简短
17 陈震离职祝福语简短
18 打麻将祝福语简短英文