A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 秦二江 中级黑马   /  2013-5-2 15:25  /  1266 人查看  /  3 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

本帖最后由 秦二江 于 2013-5-3 00:43 编辑

<html>
        <head>
               <title></title>
              <style type ="text/css">
            div
            {
              margin-left:auto;
              margin-right:auto;
              margin-top :100px;
              width:350px;
            }
        </style>
        </head>
<body>
   
    <div>
    <table>
    <tr><td>姓名:</td><td ><input type="text" /></td></tr>
    </table>
    </div>

</body>

</html>

这个 margin-left:100px; 还能起作用,但 margin-left:auto; 没反应,缓存也都清了

评分

参与人数 1技术分 +1 收起 理由
苏波 + 1

查看全部评分

3 个回复

倒序浏览
本帖最后由 付银攀 于 2013-5-2 16:04 编辑
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>无标题文档</title>
  6. </head>

  7. <style type ="text/css">
  8. div
  9. {
  10. margin-left:auto;
  11. margin-right:auto;
  12. margin-top :100px;
  13. width:350px;
  14. }
  15. </style>
  16. </head>
  17. <body>

  18. <div>
  19. <table>
  20. <tr><td>姓名:</td><td ><input type="text" /></td></tr>
  21. </table>
  22. </div>
  23. </body>
  24. </html>
复制代码
你那个代码在火狐浏览器中可以居中,在ie中是不行的,加上网页的一些基本信息后就看可以了 ,lz去测试下吧

评分

参与人数 1技术分 +1 收起 理由
苏波 + 1

查看全部评分

回复 使用道具 举报
付银攀 发表于 2013-5-2 15:50
你那个代码在火狐浏览器中可以居中,在ie中是不行的,加上网页的一些基本信息后就看可以了 ,lz去测试下吧 ...

谢谢,加个文档头就好了,我在VS里 建的不是web应用程序,所以他没有文档头,应该是不符合 为w3c  标准
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马