我的页面布局全都采用DIV做,在DW下,先用DIV画出框来,然后才在里面加控件,文件,==的。这个居中怎么搞呀。我看了别人的办法1是将当前页面剪下来,然后,画一大个表格,选表格居中,再把东西粘上去,结果是没居中2是在BODY下加<DIV ALIGN=“CENTER”></BODY>前加</DIV>,结果也是没居中,急急呀
明天东西就要拿出来了,请各位GGJJ指点了,多谢

解决方案 »

  1.   

    不懂
    我也是用div布局的。不知道楼主什么意思?
      

  2.   

    <div style="text-align:center">
      

  3.   


    <html>
    <head></head>
    <body>
    <center><div style="text-align:center;border:1px solid gray;margin-left:10%;margin-right:10%;">......</div>
    <div style="text-align:center;border:1px solid gray">......</div>
    </center>
    </body>
    </html>
      

  4.   

    用table肯定可以的。把你的html贴出来瞧瞧
      

  5.   

    你可以在CSS里面自己定义一下
    float:left这个定义层是向左排列
    clear:none/both.....定义一行只显示放这一个层
    vertical-align:定义层的排列对齐方式(针对Y)
    还有什么margin-top/bottom/left/right和padding-top/bottom/left/right通过这些来定义层的位置吧
      

  6.   

    <html> 
    <head> 
    <style type="text/css">
    body{text-align:center;}
    .a{margin:0 auto;}
    </style>
    </head> <body> <div class="a">...... </div>  
    </body> 
    </html> 
      

  7.   

    把你的代码贴出来看看,table肯定可以实现
      

  8.   

    <%@ Page Language="C#" ContentType="text/html" ResponseEncoding="gb2312" AutoEventWireup="true"  CodeFile="main.aspx.cs" Inherits="main"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>XXXXXXXXX-欢迎访问</title>
    <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);function killErrors()
    {
        return true;
    }function ErrorMessage1()
    {
        alert("您已经登录了.如果您想以其它用户名登录,那么请先将当前登录的用户注销!");
    }function ErrorMessage2()
    {
        alert("您已经登录了.如果您想注册新用户,那么请先将当前登录的用户注销!");
    }//-->
    </script>
    <style type="text/css">
    <!--
    body,td,th {
    font-size: 12px;
    }
    .style3 {color: #663300}
    .style7 {color: #000000}
    a {
    font-size: 12px;
    color: #3399FF;
    }
    .style15 {font-size: 36px}
    .style16 {
    font-size: x-large;
    font-weight: bold;
    font-style: italic;
    }
    a:link {
    text-decoration: none;
    color: #3366FF;
    }
    a:visited {
    text-decoration: none;
    }
    a:hover {
    text-decoration: underline;
    color: #FF0000;
    }
    a:active {
    text-decoration: none;
    }
    .style19 {color: #666666}
    .style21 {color: #990000}
    .style22 {color: #993366}
    .Notice_BigTitle 
    {
    font-size: 24px;
    color: #CC0000;
    }
    .Notice_Title
    {
    font-size:12px;
    color:#808080;
    }
    .style24 {color: #993300}
    -->
    </style><style>
    .Label_Notice
    {
        width:430px;
        text-overflow:ellipsis; 
        overflow:hidden; 
        white-space:nowrap; 
        word-break:keep-all;
    }
    </style><style>
    .Label_Doc
    {
        width:193px;
        text-overflow:ellipsis; 
        overflow:hidden; 
        white-space:nowrap; 
        word-break:keep-all;
    }
    </style><meta name="Microsoft Theme" content="rmnsque 011">
    </head>
    <body onload="SetTime();" background="romtextb.jpg" bgcolor="#CCCC99" text="#000000" alink="#336600">
    <form id="MainPage" runat="server">
    <div id="Layer40" style="position:absolute; left:764px; top:185px; width:153px; height:16px; z-index:51">
        <asp:Label ID="Label_DutyDate" runat="server" Height="14px"></asp:Label></div>
    <div id="Layer38" style="position:absolute; left:641px; top:694px; width:44px; height:13px; z-index:41"><a href="Public/WorkInfoMore.aspx"><img src="Main/more.gif" width="44" height="13" border="0"></a></div>
    <div id="Layer7" style="position:absolute; left:330px; top:115px; width:590px; height:20px; z-index:42">
    <marquee behavior="scroll" direction="left" loop="-1" scrollamount="1" style="font:12px;" onMouseOver="this.stop();" onMouseOut="this.start();">
    欢迎您访问 XXXXXXXXXXXX公众信息平台    本站域名http://192.168.10.124</marquee></div>
    <div id="Layer43" style="position:absolute; left:350px; top:190px; width:326px; height:170px; z-index:48; color: #CC0000;">
    <marquee behavior="slide" direction="up" width="326px" loop="1" scrollamount="1" style="height: 174px">
    <div align="center"><strong><span class="Notice_BigTitle"></span></strong></div>
    <div align="left">
        <div align="center"><asp:Label ID="Label_Notice" runat="server" Height="30px" Text="通          知" Width="186px" Font-Bold="True" Font-Size="X-Large"></asp:Label><br /></div>
          <asp:Label ID="Label_Notice_Title" runat="server" Height="22px" Width="324px" ForeColor="Gray" Font-Size="Larger" Font-Bold="True">各处室部门:</asp:Label><br />
          <asp:HyperLink ID="Label_Notice_Text" Target="_blank" runat="server" Height="96px" Width="326px" ForeColor="Gray" ToolTip="点击查看"></asp:HyperLink><br />
          <asp:Label ID="Label_Notice_End" runat="server" Text="特此通知!" Width="323px" Font-Bold="True" ForeColor="Gray"></asp:Label><br />
          <div align="right">
          <asp:Label ID="Label_Notice_Department" runat="server" Height="16px" Width="320px" ForeColor="Gray"></asp:Label><br />
          </div>
    </div>
    </marquee>
    </div>
    <div align="left"></div>
    <div id="Layer25" style="position:absolute; left:115px; top:302px; width:90px; height:20px; z-index:27">
        <asp:CheckBox ID="Check_AddUser" runat="server" ForeColor="Navy" Text="记住用户名" /></div>
    <div id="Layer26" style="position:absolute; left:215px; top:307px; width:80px; height:20px; z-index:28">
        <asp:LinkButton ID="Link_DelCookies" runat="server" ForeColor="#804000">[删除cookies]</asp:LinkButton></div>
    <div id="Layer27" style="position:absolute; left:115px; top:339px; width:60px; height:20px; z-index:29">
        <asp:ImageButton ID="Button_Enter" runat="server" Height="20px" ImageUrl="~/Main/enter.gif"
            ToolTip="登录" Width="60px" OnClick="Button_Enter_Click" CausesValidation="False" TabIndex="3" /></div>
    <div id="Layer28" style="position:absolute; left:183px; top:339px; width:60px; height:20px; z-index:30">
        <asp:ImageButton ID="Button_Register" runat="server" Height="20px" ImageUrl="~/Main/register.gif"
            ToolTip="注册新用户" Width="60px" OnClick="Button_Register_Click" /></div>
    <div id="Layer29" style="position:absolute; left:249px; top:345px; width:55px; height:20px; z-index:31; color: #ff6633;">忘记密码</div>
    <div id="Layer30" style="position:absolute; left:100px; top:690px; width:210px; height:20px; z-index:32"><img src="Main/left3.jpg" width="210" height="20"></div>
    <div id="Layer31" style="position:absolute; left:100px; top:710px; width:210px; height:250px; z-index:33">
      <table width="210" height="250" border="0" cellpadding="1" cellspacing="1" bgcolor="#999999">
        <tr>
          <td background="romtextb.jpg">&nbsp;</td>
        </tr>
      </table>
    </div>
    <div id="Layer16" style="position:absolute; left:126px; top:694px; width:14px; height:14px; z-index:34"><img src="Main/left2_logo.gif" width="14" height="14"></div>
    <div id="Layer32" style="position:absolute; left:330px; top:690px; width:364px; height:20px; z-index:35"><img src="Main/mid3.jpg" width="364" height="20"></div>
    <div id="Layer33" style="position:absolute; left:330px; top:710px; width:597px; height:250px; z-index:36">
      <table width="597" height="250" border="0" cellpadding="1" cellspacing="1" bgcolor="#999999">
        <tr>
          <td background="romtextb.jpg">&nbsp;</td>
        </tr>
      </table>
    </div>
    <div id="Layer34" style="position:absolute; left:800px; top:40px; width:100px; height:60px; z-index:37">
      <table width="100" height="60" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td width="21"><img src="Main/sethome.gif" width="14" height="14"></td>
          <td width="79" style="color: #666666"><a href=# onClick="this.style.behavior='url(#default#homepage)';this.setHomePage('http://192.168.0.100');" style="color:#666666">设为首页</a></td>
        </tr>
        <tr>
          <td><img src="Main/setsave.gif" width="14" height="14"></td>
          <td style="color: #666666"><a href=# onclick="window.external.AddFavorite(location.href, document.title)" style="color:#666666">加入收藏</a></td>
        </tr>
        <tr>
          <td><img src="Main/setemail.png" width="16" height="16"></td>
          <td><a href="mailto:[email protected]" style="color:#666666">联系我们</a></td>
        </tr>
      </table>
    </div>...........
    </div>
    </from>
    </body>
    </html>
      

  9.   


    <div style="margin:0 auto;width:200px;background-color:red;"></div>
    这样就居中了
      

  10.   

    看看,3Q了,大家.
    真是问题不断,用VS2005直接运行没错误,在IIS里运行,可以读数据库,但是写数据库的时候就是组件错误.接着search中...
      

  11.   

    这个DIV是最外层的,对吧.我刚才看了,从1028*768 换成1280*1024就不居中了
      

  12.   

    问题已解决,不过都不是你们上面说的,是用Js做的,Js取屏幕宽(1024*768)取到1024,然后 (1024-最大最外层DIV宽)/2,在<body onload时调用,把结果给div 的left还是感谢大家