[英]Apply animation in css3?
我昨天剛遇到animate.css
,想將其應用到我的網站。 但是問題是它只能工作一次,無論我將鼠標懸停在div上多少次,它都保持不變! 也許我不太了解編碼技術。 這是我的代碼:
window.setTimeout( function(){
$('#test').removeClass('animated bounce')},
1300);
$(function(){
$('#test').hover(function(){
$('#test').addClass('animated bounce');
});
});
感謝所有建議!
嘗試這個
$('#test').hover(function(){
$(this).addClass('animated bounce');
}, function(){
$(this).removeClass('animated-bounce');
});
甚至更好
$('#test').hover(function(){
$(this).addClass('animated-bounce');
});
var element = document.getElementById('test');
element.addEventListener("webkitAnimationEnd", function(){
$(element).removeClass('animated-bounce');
}, false);
其實。
為什么不只使用CSS
#test:hover{
animation: animateName ....;
}
您遇到的問題是,當您添加類時,動畫會起作用,但是當您再次懸停時,它不會再添加類,因為它已經存在,因此CSS
不知道您何時將其懸停而無需更改類名稱。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.