jQuery 动画
我用 jQuery 制作了一个动画,一切都写正确,但它不起作用! DX 谁能帮帮我吗?
$(document).ready(function(){
$('#cloud1').css({backgroundPosition: '0 -80px'});
$('#cloud2').css({backgroundPosition: '0 -30px'});
$('#cloud1').animate({backgroundPosition: '(-500px -80px)'}, 20000);
$('#cloud2').animate({backgroundPosition: '(-625px -30px)'}, 20000);
});
I made an animation with jQuery, everything is written correctly but it doesn't work!!! DX Could anyone help me?
$(document).ready(function(){
$('#cloud1').css({backgroundPosition: '0 -80px'});
$('#cloud2').css({backgroundPosition: '0 -30px'});
$('#cloud1').animate({backgroundPosition: '(-500px -80px)'}, 20000);
$('#cloud2').animate({backgroundPosition: '(-625px -30px)'}, 20000);
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以在这里看到 jQuery 可以做什么。这是一个简单的(有几个需要修复的错误)游戏。
您可以在代码中找到您可能需要的所有 jQuery 残酷性,并且充满了循环和其他东西!看一下:
http://roxon.in/scripts/articlesExplosionGame/
推荐浏览器:Opera、Chrome (两者都有一个很棒的 JS 引擎!)
或者如果您愿意,您可以阅读我的这个简单教程(也有循环!计数器和所有有趣的 jQuery 东西!):
http://roxon.in/scripts/tutorials/NavGallery_jQuery_Tutorial_01/
但总是......总是去参考 jQuery 官方 API 页面。当然还有堆栈溢出。
并在这里查看“弹跳”(缓动)、滑块等:http://jqueryui.com/demos/
在这里,我为您准备了一个有趣的
具有随机位置和速度的DEMO循环动画
我评论了我的代码确实可以帮助你 理解!
更改数字,添加更多汽车,玩得开心!
PS:要添加更多汽车,您必须学习 jQuery .each() 函数方法;)并尝试实现它!
(好吧,开个玩笑 - 但这很简单。自己找找吧!多辆车演示!)
You can see here what can jQuery do. Here is a simple (with fiew bugs to fix) game.
You can find in the code all the jQuery brutality you may need, and is full of loops and other things! Take a look:
http://roxon.in/scripts/particlesExplosionGame/
recommended browsers: Opera, Chrome (both have a great JS engine!)
Or if you want you can go through this easy tutorial of mine (has loops too! counters and all the fun jQuery stuff!) :
http://roxon.in/scripts/tutorials/NavGallery_jQuery_Tutorial_01/
But always ... always go for reference to the jQuery official API pages. And Stack Overflow of course.
And take a look for 'bounces' (easings) , sliders and so on here: http://jqueryui.com/demos/
Here, I prepared to you a fun
DEMO loops animation with random positions and speed
I commented my code do help you understand!
Change the numbers, add more cars, have fun!
P.S. : to add more cars you'll have to learn the jQuery .each() function method ;) and try to implement it!
(Ok, just kidding - but it's easy. look for your self! DEMO with multiple cars!)
使用官方 jQuery API 不会出错。请参阅 .animate()。
You can't go wrong with the official jQuery API. See .animate().
取自文档
http://api.jquery.com/animate/
会将当前宽度更改为 70% 1.5 秒内
Taken from documentation
http://api.jquery.com/animate/
will change current width to 70% in 1,5 second