在一个网页中有一幅对联 分别 在网页的左右两边  现在需要实现的 是 怎么使对联随着滚动条
上下移动而 弹动(就是向下滚动时那对联向下跳动跳动的距离与滚动的距离一样    向上同样)

解决方案 »

  1.   

    你可以搜索 css position fixed ,这样是不会跳动的,很稳定。搜索结果中也有IE6不支持position:fixed 的解决办法。 
      

  2.   

    document.documentElement.scrollTop可以取到滚动条的滚动距离,广告跟着移动同样的距离就行了
      

  3.   

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <style type="text/css" >
    #div1
    {
    position:fixed !important; position:absolute; top:0px; left:0px; width:50px; height:300px; background-color:#aaa;
    }#div2
    {
    position:fixed !important; position:absolute; top:0px; right:0px; width:50px; height:300px; background-color:#aaa;
    }</style>
    <script language="javascript">
    window.onscroll = /MSIE/.test(navigator.userAgent) ? function() {
    document.getElementById("div1").style.top = document.body.scrollTop + "px";
    document.getElementById("div2").style.top = document.body.scrollTop + "px";
    } : null;
    </script>
    </head>
    <body>
    <div id="div1">aa</div><div id="div2">bb</div>
    <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
    <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
    </body>
    </html>