点击旋转字体真棒图标
我正在尝试使字体真棒雪佛龙点击旋转180º。点击旋转字体真棒图标
这是JSFiddle的小提琴,有我到目前为止尝试过的。我也想让它绕着中心旋转,所以我用了其他thread。
HTML
<div class="fa fa-chevron-up"><a href="#">^</a></div>
CSS
.rotate {
-webkit-animation: spin1 2s linear;
-moz-animation: spin1 2s linear;
-o-animation: spin1 2s linear;
-ms-animation: spin1 2s linear;
animation: spin1 2s linear;
-webkit-transform-origin: 50% 50%;
-moz-transform-origin: 50% 50%;
-o-transform-origin: 50% 50%;
transform-origin: 50% 50%;
width: 256px;
height: 256px;
}
@-webkit-keyframes spin1 {
0% { -webkit-transform: rotate(0deg);}
100% { -webkit-transform: rotate(180deg);}
}
@-moz-keyframes spin1 {
0% { -moz-transform: rotate(0deg); }
100% { -moz-transform: rotate(180deg);}
}
@-o-keyframes spin1 {
0% { -o-transform: rotate(0deg);}
100% { -o-transform: rotate(180deg);}
}
@-ms-keyframes spin1 {
0% { -ms-transform: rotate(0deg);}
100% { -ms-transform: rotate(180deg);}
}
@-keyframes spin1 {
0% { transform: rotate(0deg); }
100% { transform: rotate(180deg);}
}
JS
$(".fa-chevron-up").click(function(){
$(this).toggleClass("rotate") ;
})
我相信它会更容易与CSS transitio做到这一点NS:
CSS
.rotate{
-moz-transition: all 2s linear;
-webkit-transition: all 2s linear;
transition: all 2s linear;
}
.rotate.down{
-ms-transform: rotate(180deg);
-moz-transform: rotate(180deg);
-webkit-transform: rotate(180deg);
transform: rotate(180deg);
}
jQuery的
$(".rotate").click(function(){
$(this).toggleClass("down");
});
+1如果列出所有可能的前缀,可以避免转换all。 '-ms-transform'也可以为IE9添加,尽管它不会转换(因为它不被支持)。 – 2014-10-03 05:05:39
它不适用于Android应用程序。 – 2016-08-25 05:59:20
非常有用,有时尝试思考如果不添加,变换剂量不起作用:显示:块或显示:内嵌块 – 2017-02-27 14:18:52
那么,什么是你的问题? – APerson 2014-10-03 04:43:20
当您点击小提琴中的链接时,它不会触发JS或看起来执行任何操作 – rohit 2014-10-03 04:45:18
jquery从小提琴中缺失。它在那里工作正常 – kellycode 2014-10-03 04:48:53