日期:2014-05-16  浏览次数:20401 次

问问论坛里面的各位有没有会的或收藏这样的特效
就是背景图片会左右晃动,有点电影的感觉,请问是flash做的还是js写出来的,如果碰巧有会的或者收藏的能不能晒一下~~

------解决方案--------------------
通过js控制background-position样式吗?
------解决方案--------------------
HTML code

<html>
    <head>
        <title></title>
        <style>
            .bg1 {
                width:300px;
                height:300px;
                background-image:url('a.jpg');
                background-position-x:-100px;
                background-position-y:0px;
            }
            .bg2 {
                width:300px;
                height:300px;
                background-image:url('a.jpg');
                background-position-x:-140px;
                background-position-y:0px;
            }
        </style>
        <script>
            var index = 0;
            function f_onload(){
                var vv = setInterval("next()",100);
            }
            
            function next(){
                index ++;
                if(index % 2 == 0){
                    document.getElementById("bg").className = "bg1";
                }else{
                    document.getElementById("bg").className = "bg2";
                }
            }
        </script>
    </head>
    <body onload="f_onload();">
        <div id="bg" class="bg1">
            &nbsp;
        </div>
    </body>
</html>