js怎么让div始终靠窗体右下角 ,随着最大/小化,即使拉动窗体的宽度也不变。怎么实现,哥哥姐姐们?

解决方案 »

  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=gb2312" />
    <title>test</title>
    <style>
    html {background:#ccc;}
    body {margin:0; padding:0 10px 0 10px; border:0; height:100%; overflow:auto; background:#ccc;}
    body {font-family: georgia, serif; font-size:12px;}
    #menu {display:block; bottom:2px; right:2px; width:130px; position:fixed; border:1px solid #990000; padding:10px; text-align:center; font-weight:bold; color:#990000; background:#fff;}
    * html #menu {position:absolute;}/*only for ie*/
    </style>
    <!--[if IE 6]> <style type="text/css"> /*<![CDATA[*/ html {overflow-x:auto; overflow-y:hidden;} /*]]>*/ </style><![endif]-->
    </head>
    <body>
    <div style="background-color:#aa1234;width:200px;height:1000px">
    <div id="menu">容器</div>
    </div>
    <div style="height:2000px;">2</div>
    </body>
    </html>
      

  2.   

    position:[fixed];属性值更改为[absolute] 
      

  3.   

    css就可以了,没必要用js,
    style="border:1px;bottom:1px;right:1px"
      

  4.   

    用document.body.clientWidth  document.body.clientHeight来计算页面的高和宽,
      

  5.   

    谢了1楼兄弟, bottom:2px; right:2px; 这两个样式是关键。