如何使用JavaScript设置过渡效果的CSS属性?
使用JavaScript中的transitionProperty 设置CSS属性。您可以尝试运行以下代码以返回过渡效果适用于JavaScript的CSS属性-
示例
<!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 3s;
}
#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.transitionProperty = "width,height";
}
</script>
</body>
</html>热门推荐
10 开盘大吉的简短祝福语
11 客户新房祝福语简短大气
12 赛前祝福语加姓名简短
13 写给女友的祝福语++简短
14 给儿子新婚祝福语简短
15 中秋祝福语简短带署名
16 官宣祝福语简短霸气
17 婚礼红包祝福语简短霸气
18 校庆祝福语简短横幅