听说div+css能完全替代table的布局功能,那怎样用div+css使一篇文章或控件显示在ie的中间呀,能举个例子看看吗?

解决方案 »

  1.   

    <div style="text-align:center;width:100%;">控件放这里</div>
    这样在IE是可以的,但是火狐是不支持的
      

  2.   

    <!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>无标题文档</title>
    </head><body style="width:100%">
    <div style="text-align:center;width:100%;"><input name="" type="text" value="控件放这里" /></div>
    </body>
    </html>给你个完整的,我试了下,好像火狐又可以了
    我现在也不敢肯定了。^_^
      

  3.   

    <body>
    <center>
    其它放这里
    </center>
    </body>
      

  4.   

    text-align:center会使div的内容也居中
    <style>
    #warp {
      position: absolute;
      width:500px;
      height:200px;
      left:50%;
      top:50%;
      margin-left:-250px;
      margin-top:-100px;
      border: solid 3px red;
    }
    </style>
    <body>
      <div id=warp>Test</div>
    </body>原理很简单:将left和top设置为50%来定位div到浏览器中央,再将margin-left和margin-top值设置为宽和高的一半,使div居中显示。
      

  5.   

    谢谢各位的帮助,小弟会永远记住的。“cteddy”不好意思呀,加分加错了,下次我一定给你多加点!