<style type="text/css"> #a{ width:300px; height:200px; overflow:hidden; position:relative; } img{width:300px; height:200px; } #b{ width:1200px; height:200px; position:absolute; } </style> <script type="text/javascript"> var i=0; function qu() { var temp=300*i console.log(temp); document.getElementById('b').style.left='-'+temp+'px'; setTimeout('qu()',2000); i++; } </script>