0
我的精靈動畫完美地完成奇怪的點擊(1,3,5 ....),使開關處於向下位置,但我無法獲得均勻點擊( 2,4,6 ...)來啓動將開關置於上位的動畫。跨瀏覽器CSS從帖子中刪除,但在小提琴中。Skeuomorphic開關CSS3精靈動畫只能工作一半時間
HTML
<div class="switch s-up"></div>
jQuery的
$(document).ready(function() {
$(".switch").click(function() {
$(this).toggleClass("s-down s-up");
});
})
CSS
.switch{
background: transparent url(http://i.imgur.com/taIR0.jpg);
height:65px;
width: 75px;
margin-bottom:75px;
cursor:pointer;
}
.s-down{
animation: play .4s steps(5);
}
.s-up{
animation: reverse .4s steps(5);
}
.switch.s-down{
background: transparent url(http://i.imgur.com/taIR0.jpg) -300px 0;
}
@keyframes play {
0% { background-position: 0px; }
100% { background-position: -375px; }
}
@keyframes reverse {
0% { background-position: -375px; }
100% { background-position: 0px; }
}
爲什麼你使用'div'?爲什麼不使用「按鈕」(或至少是ARIA角色)?點擊按鈕,輸入類型提交,圖像,按鈕和鏈接; 'div'不是 – FelipeAls
是的,我可以使用按鈕而不是div,但是您的評論與我的問題沒有關係。切換出來不會使動畫的工作方式不同。 – coreballs
我沒有回答你的問題,而是評論你的代碼。這就是爲什麼我在SO問題下使用註釋部分而不是「您的答案」部分。 – FelipeAls