HTML DOM TransitionEvent propertyName 属性
htmlweb developmentfront end technology更新于 2024/3/20 23:08:17
HTML DOM TransitionEvent propertyName 属性返回一个字符串,该字符串对应于触发过渡事件时用于过渡的 CSS 属性。
以下是语法 −
返回过渡所使用的 CSS 属性 −
transitionEvent.propertyName
让我们看一个 TransitionEvent propertyName 属性的示例 −
示例
<!DOCTYPE html>
<html>
<head>
<title>TransitionEvent propertyName</title>
<style>
form {
width:70%;
margin: 0 auto;
text-align: center;
}
* {
padding: 2px;
margin:5px;
}
input[type="button"] {
border-radius: 10px;
}
#playArea {
display: inline-block;
border-radius: 50%;
background-color: #DC3545;
width: 50px;
height: 50px;
border: 3px solid #AC3509;
transition: all 1.3s ease;
}
#playArea:hover {
transform:translateX(80px);
}
</style>
</head>
<body>
<form>
<fieldset>
<legend>TransitionEvent-propertyName</legend>
<div id="playArea"></div>
<div id="divDisplay"></div>
</fieldset>
</form>
<script>
var divDisplay = document.getElementById("divDisplay");
var playDisplay = document.getElementById("playArea");
function getPropertyName(event) {
divDisplay.textContent = 'CSS Property Used for Transition: '+event.propertyName;
}
playDisplay.addEventListener("transitionend", getPropertyName);
</script>
</body>
</html>
输出
鼠标悬停在 div 元素上之前 −

鼠标悬停在 div 元素上之后 −

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

