我是 html5、css 和 javascript 的新手,而且大多数时候我只是在玩。我想要做的是设置和触发 div 的转换。页面加载后,我设法通过设置转换来做到这一点。但这感觉不是很有活力,似乎也不是正确的方法。我很感谢任何帮助
<!DOCTYPE html>
<html>
<head>
<style>
body{
text-align: center;
}
#dialPointer
{
position:relative;
margin-left: auto;
margin-right: auto;
width:23px;
height:281px;
background:url(pointer.png);
background-size:100% 100%;
background-repeat:no-repeat;
transform: rotate(-150deg);
transition-duration: 2s;
transition-delay: 2s;
-webkit-transform: rotate(-150deg);
-webkit-transition-duration:2s;
-webkit-transition-delay: 2s;
}
/* I want to call this once */
.didLoad
{
width:23px;
height:281px;
transform:rotate(110deg);
-moz-transform:rotate(110deg); /* Firefox 4 */
-webkit-transform:rotate(110deg); /* Safari and Chrome */
-o-transform:rotate(110deg); /* Opera */
}
</style>
</head>
<body>
<div id="dialPointer"></div>
<script language="javascript" type="text/javascript">
window.onload=function () {
//But instead of using rotate(110deg), I would like to call "didLoad"
document.getElementById("dialPointer").style.webkitTransform = "rotate(110deg)";
};
</script>
</body>
</html>