代码之家  ›  专栏  ›  技术社区  ›  Albert

身体边距:0,事业部宽度:100%FF和Chrome有问题,IE没问题

  •  0
  • Albert  · 技术社区  · 16 年前

    我有以下内容:

    <html>
    <head>
    <style>
        body { margin:0 auto; }
    </style>
    </head>
    <body>
        <div style="border: solid 1px red; width: 100%;">test</div>
    </body>
    </html>
    

    这工作在IE产生一个很好的div,100%宽度,没有H滚动条。。。

    为什么?我应该用什么代替呢?

    谢谢! 艾伯特

    编辑:

    我在头部添加了div{margin:0;}并去掉了宽度:100%,这样就可以了,谢谢。

    5 回复  |  直到 16 年前
        1
  •  3
  •   fuxia    16 年前

    这个 border 坐在外面 width 100% + 2px 宽度

        2
  •  1
  •   Raffael Luthiger    16 年前

    正如拾荒者已经指出的。分歧的边缘是问题所在。使用以下命令重置所有内容:

    <style>
      * { margin:0; }
    </style>
    

    this article 关于将所有浏览器中的CSS重置为相同的默认值。

        3
  •  0
  •   Wander Nauta    16 年前

    你忘了禁用div的边距。

        4
  •  0
  •   Mironline Naeem Bashir    16 年前

    width:100% 通过 margin:0px

        5
  •  0
  •   Community Mohan Dere    9 年前

    <div style="zoom: 1;">
        <div style="zoom: 1;">
            <table style="width: 100%"...
            ...
            </table>
        </div>
    </div>
    

    DIV with overflow:auto and a 100% wide table