只改变背景图的横向位置(或者纵向位置).javascript怎么写
两个同时改又怎么写

解决方案 »

  1.   

    楼主 这个意思?看6楼
    http://topic.csdn.net/u/20120520/16/d2f80612-420a-4e8c-9490-9696679416cb.html
      

  2.   


    <!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>
      

  3.   

    Object.style.backgroundPositionX=position //横向
    Object.style.backgroundPositionY=position //竖向
      

  4.   


    请问 obj.style.backgroundPosition = '0 '+(--i)+'px';
    这一句里面的,我只要设置第二个参数,第一个参数保持原来的,应该怎么做吖??