请问怎样让图片360度旋转

jabez_zhang 2013-03-12 02:59:31
我在写网页的时候想让其中一张图片实现360度旋转,用js不用css3
在谷歌上找到了一个叫jqueryrotate.js的文件
地址:http://code.google.com/p/jqueryrotate/wiki/Examples
作者说可以用其中包含的函数实现图片旋转功能,并做了演示
但是当我按照作者示范在写了代码,甚至是原本搬运代码,都没有实现图片旋转的功能
<html>
<head>
<script type="text/javascript" src="http://jqueryrotate.googlecode.com/svn/trunk/jQueryRotate.js"></script>
<script type="text/javascript">
var rotation = function (){
$("#img").rotate({
angle:0,
animateTo:360,
callback: rotation,
easing: function (x,t,b,c,d){ // t: current time, b: begInnIng value, c: change In value, d: duration
return c*(t/d)+b;
}
});
}
rotation();
</script>
</head>
<body>
<img style="margin:10px;"src="/arrow.png" id="img">
</body>
</html>
我以为是浏览器的问题,换了chrome,ie,firefox均不行
纠结了好几个小时,实在没找出问题在哪
请善良的同志们给点意见!
要是能顺便附上一段成功运行的代码范例的话那就最好了!
...全文
274 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
菜牛 2013-03-12
  • 打赏
  • 举报
回复
我想你有两个问题,第一个是没有引入jQuery库,另一个是,你确定旋转360°你能和原图区别出来?
001007009 2013-03-12
  • 打赏
  • 举报
回复
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="http://jqueryrotate.googlecode.com/svn/trunk/jQueryRotate.js"></script>

</head>
<body>
<img style="margin:10px;"src="http://www.baidu.com/img/shouye_b5486898c692066bd2cbaeda86d74448.gif" id="img">
<script type="text/javascript">
var rotation = function (){
   $("#img").rotate({
      angle:0, 
      animateTo:360, 
      callback: rotation,
      easing: function (x,t,b,c,d){
	  // t: current time, b: begInnIng value, c: change In value, d: duration
          return c*(t/d)+b;
      }
   });
}
rotation();
</script>
</body>
</html>
jabez_zhang 2013-03-12
  • 打赏
  • 举报
回复
已经试过了...noway...
chaoren1641 2013-03-12
  • 打赏
  • 举报
回复
把JS调用代码放到<img后面去,或者写到document.ready里!
jabez_zhang 2013-03-12
  • 打赏
  • 举报
回复
BTY:把script包含在$(document).ready(function(){})里面也不对。。。

87,910

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧