背景图动起来就这么简单!
<!DOCTYPE HTML> <html lang="en-gb" class="nojs"> <head> <meta charset="utf-8"> <meta name="viewport" content="initial-scale=1.0" /> <title>无标题文档</title> <link rel="stylesheet" href="reset.css" /> <style type="text/css"> body{ background-image:url(img/bodyBg.jpg)} img{ width:100%; background:url(2.jpg) no-repeat} </style> </head> <body> <section> <img id="banner" src="img/banner.jpg" /> </section> </body> <script src="jquery.min.js"></script> <script> $(function(){ k=0; function run(k){ $('body').css('backgroundPosition',k+"px") } setInterval(function(){k-=1;run(k)},50); }) </script> </html>