當鼠標懸停在元素中時,我需要動畫,但是當用戶使鼠標懸停時,動畫停止在本地當前。當鼠標懸停在元素JS或Jquery中時循環
countRotate = 0;
adiciona = true;
$('.circulo-left').mouseenter(function(){
$('#circuloprincipalcomabaazulclaro').css('transform', 'rotate('+countRotate+'deg)');
if(adiciona == true){
countRotate++;
if(countRotate == 360){
adiciona = false;
}
}else{
countRotate = countRotate - 1;
if(countRotate == 0){
adiciona = true;
}
}
});
// I thought of something like that.
.circle{
width:200px;
height:200px;
border-radius:50%;
border
}
.circle:hover{
#circuloprincipalcomabaazulclaro{
@include animation(rotate 3s infinite alternate);
}
}
@keyframes rotate {
from{
transform: rotate(0deg);
}
to{
transform: rotate(360deg);
}
}
/* But when I remove the mouse it returns to the starting point. */
<div class="circle"></div>
我們都很好,謝謝關心。請分享您嘗試過的內容並閱讀[MCVE](http://stackoverflow.com/help/mcve) – philantrovert
我們需要[mcve]比任何事情都重要。 –
代碼段不起作用。你需要包含jquery。 – G0dsquad