我想停止輸入焦點上的跨度動畫。我無法停止焦點上的css/jquery動畫
當我做懸停時,沒有問題,總是很好。但是當我關注輸入時我想停止跨度。問題在這裏。我的代碼是here。
Actualy我想用css而不是scss來做這件事。 here
和HTML:
<link href='https://fonts.googleapis.com/css?family=Open+Sans:300' rel='stylesheet' type='text/css'>
<section id="text">
<p><span> İSİM</span><input name="name" type="text" placeholder="İsminiz" /></p>
<p><span> KONU </span><input name="subject" type="text" placeholder="Konu"/></p>
<p><span> MAİL </span><input name="mail" type="email" placeholder="Mailiniz"/></p>
<p><span> MESAJ </span><textarea name="message" type="text" placeholder="Mesajınız"></textarea>
</section>
CSS:
.aktif1{width:100px;transition:1s;}
.aktif2{width:450px;transition:1s;}
body{
background:#f7f7f7;
}
p{
position: relative;
width:450px;
}
section#text{
position:relative;
margin-left:500px;
margin-top:150px;
}
p input{
outline:none;
width:330px;
height:40px;
padding-left:120px;
}
p textarea{
outline:none;
max-width:330px;
max-height:40px;
width:330px;
height:40px;
padding-left:120px;
}
p span{
width:455px;
height:45px;
background:#333;
position: absolute;
color:white;
text-align:center;
line-height:50px;
font-family: 'Open Sans', sans-serif;
font-weight:bold;
transition:1s;
}
的Jquery:
$(function() {
fonk1();
$('section#text input').focus(function(){
fonk1().stop();
});
fonk2();
$('section#text input').blur(function(){
fonk2();
});
});
var fonk1 = function(){
$('section#text p').mouseenter(function(){
$('span',this).animate(1000,function(){
$(this).css({'width':'100'});
});
});
}
var fonk2 = function(){
$('section#text p').mouseleave(function(){
$('span',this).animate(1000,function(){
$(this).css({'width':'450'});
});
});
}
如果您希望第一個codepen相同**在CSS窗口中查看已編譯的CSS ** ...,請單擊向下箭頭並選擇查看已編譯的CSS。那麼你可以看到它作爲普通的CSS – DaniP
謝謝我不知道這個功能。但我只是想知道我在代碼中的錯誤。 –
你想'一旦用戶關注輸入就停止動畫'嗎? 「停止跨度」/「停止懸停」是否意味着這種情況? – flob