日期:2014-05-16 浏览次数:20360 次
<!DOCTYPE HTML> <html> <head> <meta charset="gb2312" /> <title></title> <style> div { margin:0 auto; width:800px; /*1320*/ height:513px; background:url(http://whoisleon.com/wp-content/themes/whoisleon/images/n_cloud1.jpg) repeat; } </style> </head> <body> <div id="test"></div> <script> var $ = function(id){ return document.getElementById(id); }; var obj = $('test'); var i = 0; setInterval(function(){ obj.style.backgroundPosition = '0 '+(--i)+'px'; }, 30) </script> </body> </html>
------解决方案--------------------
Object.style.backgroundPositionX=position //横向
Object.style.backgroundPositionY=position //竖向