我試圖使用動畫,通過在頁面加載中更改jQuery中的類觸發。目前它沒有做任何事情。我不確定發生了什麼問題,雖然我很確定它的CSS有問題。這裏是我的代碼:CSS/jQuery動畫不觸發
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Page 2</title>
<style type="text/css">
/* Your styles go here */
img {width:200px; height:100px; animation-name: widthChange; animation-duration: 3s;}
.loaded {animation-name: widthChange; animation-duration: 3s;}
p {text-align:center}
button {margin:20px}
@keyframes widthChange {
from {width: 200px;}
to {width: 400px;}
}
</style>
<script src="http://code.jquery.com/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
// jQuery methods go here...
$(document).ready(function() {
$('img').addClass("loaded");
});
});
/* Your additional JavaScript goes here */
</script>
</head>
<body>
<img class = "image" src="elephant.jpg" alt="elephant"/>
<p><button>Button 1</button><button>Button 2</button><button>Button 3</button></p>
</body>
</html>