用jS 做逐帧动画
<!doctype html> <html> <head> <meta charset="utf-8"> <title>无标题文档</title> <style> #anidem{ width:320px; height:378px; background:url(img/imgs.png) no-repeat } </style> </head> <body> <div id="anidem"></div> <script> var anidem = document.getElementById("anidem"); var count=0 var counts= 0 var tsid = 0 setInterval(function() { anidem.style.backgroundPosition = ((-320*count)+"px "+(counts)+"px"); count++; if(count>=7) {count=0 counts = -430*tsid; tsid++; if(tsid>=6){ tsid=0;} } },100) </script> </body> </html>
图片 对setInterval用js 函数来做。其中要注意anidem.style.backgroundPosition = ((-320*count)+"px ") px后面的空格很重要。![](https://images2015.cnblogs.com/blog/1092956/201703/1092956-20170315120400245-569666805.png)
![](https://images2015.cnblogs.com/blog/1092956/201703/1092956-20170315120400245-569666805.png)
你在进步,骚年