<DIV id=fly1 
style="LEFT: 40%; WIDTH: 自己设px; POSITION: absolute; TOP: 40%; HEIGHT: 自己设px">

解决方案 »

  1.   

    <DIV id=fly1 
    style="LEFT: 40%; WIDTH: 自己设px; POSITION: absolute; TOP: 40%; HEIGHT: 自己设px">
      

  2.   

    永远位于正中的层
    <SCRIPT LANGUAGE="JavaScript">
    window.onload = centre;
    window.onresize = centre;
    function centre() {
    var dw = document.body.clientWidth;
    var dh = document.body.clientHeight;
    var obj = document.getElementById("c");
    var ow = obj.offsetWidth;
    var oh = obj.offsetHeight;
    with(obj.style) {
    left = dw/2-ow/2;
    top = dh/2-oh/2;
    }
    }
    </SCRIPT>
    <body>
    <div id="c" style="width:150px;height:150px;border:1px solid black;background-color:gray;position:absolute;"></div>
      

  3.   

    回: cloudchen(陈系上) 
    如果我不只一个层呢???
    如果有几个层~~~怎么办??
    谢谢!!
      

  4.   

    先将一个表格居中,然后在表格里插入一个层,再在层里插入层,多少个都可以。
    给你一个例子。
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <script language="JavaScript" type="text/JavaScript">
    <!--
    function MM_reloadPage(init) {  //reloads the window if Nav4 resized
      if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
        document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
      else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
    }
    MM_reloadPage(true);
    //-->
    </script>
    </head><body>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td align="center"><div id="Layer1" style="position:absolute; width:10px; height:10px; z-index:1">
            <div id="Layer4" style="position:absolute; width:200px; height:44px; z-index:3; background-color: #FF00FF; layer-background-color: #FF00FF; border: 1px none #000000; left: -1px; top: 26px;">层...</div>
            <br>        <div id="Layer3" style="position:absolute; width:200px; height:49px; z-index:2; background-color: #0000FF; layer-background-color: #0000FF; border: 1px none #000000; top: 74px; left: -1px;">层2</div>
           <br>
            <div id="Layer2" style="position:absolute; width:200px; height:46px; z-index:1; background-color: #993333; layer-background-color: #993333; border: 1px none #000000; left: -1px; top: 126px;">层1</div>
          </div>
          层总在我旁边 </td>
      </tr>
    </table>
    </body>
    </html>
    是这样的吧?呵呵。。