我想实现 当拉动滚动条的时候图片始终在右下角显示。。是相对屏幕静止的。并点击图片的时候返回页面的顶部。求完整代码
~~~ 谢谢~~

解决方案 »

  1.   


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <style>
    *{
    margin:0;
    padding:0;
    }
    .mock{
    height:900px;
    width:900px;
    margin:0 auto;
    background:#333;
    color:red;
    }
    .fixedImg{
    width:160px;
    height:240px;
    position:fixed;
    bottom:0;
    right:0;
    z-index:10px;
    }
    </style>
    </head>
    <body>
    <div class="mock">
    啊啊啊啊啊啊啊
    </div>
    <img src="http://farm7.static.flickr.com/6185/6075453511_63636c1b05_m.jpg" class="fixedImg" id="fixedImg" />
    <script type="text/javascript">
    function $(el){return document.getElementById(el)};
    var o = $("fixedImg");
    o.onclick = function(){
    document.body.scrollTop = 0;
    };
    </script>
    </body>
    </html>
    仅支持chrome,要用的话再写兼容的版本吧。
    1.IE6不支持fixed,用JS模拟吧。
    2.FF和IE获取scrollTop应该是document.documentElement.scrollTop,记不太清了
      

  2.   

    其实position:fixed;就挺好的 了。。