我是菜鸟,请问像http://www.discuz.net/forum.php这个网站上,点击登录,出现出现的登录框始终显示在浏览器正中央,这是怎么实现的,请详解,谢谢!
我的意思是弹出的层应该要相对浏览窗口位置固定,而不要是相对页面位置固定。

解决方案 »

  1.   

    伪窗口 通过DIV来做的。如果有兴趣直接去网上找一个去
      

  2.   

    用div做的关键就是style样式了.正常情况下会有 
    <div id="phoneDiv" style="position:absolute; z-index:1; top:290px; left:600px; display:none;">
      

  3.   

    这貌似是一个DIV啊
    控制位置那就是控制它的style嘛
      

  4.   


    <!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>
    #login{
    width:220px;
    height:100px;
    background:#999;
    border:1px solid red;
    float:left;
    position:absolute;
    z-index:1000;
    }
    #ok{
    float:left;
    margin-left:60px;
    }
    </style>
    </head> 
    <body onload="test()" onresize="test()">  
    <div id="login" >
         <label>用户名:</label><input type="text" id="username" />
         <label>密码:</label><input type="password" id="password" />
         <input type="button" id="ok" value="登录" />
         <input type="button" value="重置" />
    </div>
    </body> 
    </html>
    <script>
    function test(){
        var body_width = document.documentElement.clientWidth;
    var body_height = document.documentElement.clientHeight;
    document.getElementById("login").style.left = body_width/2 - 220/2 + "px";
    document.getElementById("login").style.top = body_height/2 - 100/2 + "px";
    //document.getElementById("login").style.marginTop = body_height/2 -100/2 + "px";
    }
    </script>
      

  5.   

    就是做一个DIV层···默认为隐藏
    为图片添加点击事件``当点击的时候将DIV显示出来·
    主要就是这个DIV的z-index属性·数值最大的就显示在最上面