如题有jquery的方法,将一个id=footer的div,始终置于屏幕的最下面吗?

解决方案 »

  1.   

    有点类似phpwind论坛,登录后,会开启一个div,始终显示在屏幕最下面,无论屏幕如何滚动,它的位置不变
      

  2.   

    看到msdn里面有个帖子,但是按照这个方法没有效果。。<!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 content="text/html; charset=utf-8" http-equiv="Content-Type" />
    <title>abc</title>
    <script type="text/javascript" src="jquery-1.4.2.js"></script>
    <script type="text/javascript">
            $(document).ready(ResetPosition);
            
            $(window).resize(ResetPosition);
            
            function ResetPosition()
            {
                   var div1 = $('#div1');
                   div1.css("top", $(window).height() - div1.height());
            }
    </script>
    </head><body><div style="height: 3000px; border-style: solid; border-width: 1px">
    </div>
    <div id="div1" style="position:fixed; height:20px">abc
    </div>
    </body></html>
    --------------------------------------------------------------------------------
      

  3.   

    发个非jquery的。
    <!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>Bottom Div</title>
    <style type="text/css">
    html,body{width:100%;height:100%;margin:0px;padding:0px;}
    #bottom{width:300px;height:250px;border:1px #FF9900 solid;background-color:#FFCCCC;position:absolute;top:0px;left:0px;visibility:hidden;}
    </style>
    <script type="text/javascript">
    window.onload = position;
    window.onresize = position;
    function position(){
        var bottomDiv = document.getElementById("bottom");
    var ch,cw,bottomWidth,bottomHeight;
    ch = document.body.clientHeight;
    cw = document.body.clientWidth;
    bottomWidth = bottomDiv.offsetWidth;
    bottomHeight = bottomDiv.offsetHeight;
    with(bottomDiv){
        style.top=(ch - bottomHeight)+"px";
        style.left=(cw - bottomWidth)+"px";
    style.visibility = "visible";
    }
    };
    </script>
    </head>
    <body>
    <div id="bottom"></div>
    </body>
    </html>
      

  4.   


    position:fixed;
    /*IE6不支持,其他浏览器通过。*/
      

  5.   

    借用下:
    <!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>Bottom Div</title>
    <style type="text/css">
    html,body{width:100%;height:100%;margin:0px;padding:0px;}
    #bottom{width:300px;height:250px;border:1px #FF9900 solid;background-color:#FFCCCC;position:absolute;top:0px;left:0px;visibility:hidden;}
    </style>
    <script type="text/javascript">
    window.onload = position;
    window.onresize = position;
    function position(){
        var bottomDiv = document.getElementById("bottom");
        var ch,cw,bottomWidth,bottomHeight;
        ch = document.body.clientHeight;
        cw = document.body.clientWidth;
        bottomWidth = bottomDiv.offsetWidth;
        bottomHeight = bottomDiv.offsetHeight;
        with(bottomDiv){
            style.top=(ch - bottomHeight)+"px";
            style.left=(cw - bottomWidth)+"px";
            style.visibility = "visible";
        }
    };
    </script>
    </head>
    <body>
    <div id="bottom"></div>
    </body>
    </html>