Air*_*qub 0 html javascript css jquery animation
<!DOCTYPE html>
<html>
<head>
<title>Alive Time</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="style.css">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
<script src="code.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js"></script>
</head>
<body>
<i class="fa fa-cog" style="font-size:100px"></i>
<i class="fa fa-arrow-right" style="font-size:100px"></i>
</body>
</html>
----------------------------------------------------------------------------
.fa-cog{
margin: 10% 50%;
color: red;
/*-moz-transition: all 0.5s linear;
-webkit-transition: all 0.5s linear;
transition: all 0.5s linear;*/
}
.down {
-moz-transform:rotate(180deg);
-webkit-transform:rotate(180deg);
transform:rotate(180deg);
}
--------------------------------------------------------------------------------------------------------------
$(document).ready(function(){
$(".fa-cog").on('mouseenter',function(){
$(this).animate({rotate:180},{
step:function(now,fx){
/*$(this).css({' -moz-transform':'rotate('+now+'deg)',
'-webkit-transform':'rotate('+now+'deg)',
'transform':'rotate('+now+'deg)'});*/
$(this).css('-webkit-transform','rotate('+now+'deg)');
$(this).css('-moz-transform','rotate('+now+'deg)');
$(this).css('transform','rotate('+now+'deg)');
},duration:'slow'},'linear');
});
});
Run Code Online (Sandbox Code Playgroud)
伙计们,我正在尝试专门使用 jquery 的 animate() 方法来旋转齿轮。我知道我可以让一个类使用一些转换、转换,然后添加或删除该类。但我想在这里使用 animate() 。stackoverflow 上的几个文档说我们实际上不必使用真正的 CSS 属性,例如 text-index 或 border-spacing,而是您可以指定一个虚假的 CSS 属性,例如旋转或 my-awesome-property 或其他。使用将来不会成为实际 CSS 属性的东西可能是个好主意。我尝试了所有无法在我的代码中找到错误的方法。忽略我注释掉的代码。
小智 7
问题出在这一行:
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
Run Code Online (Sandbox Code Playgroud)
在您的情况下,您不能使用 jQuery 的精简版,因为此版本没有动画。只需将其替换为:
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6341 次 |
| 最近记录: |