IE7边框问题

发布于 2024-07-27 22:38:17 字数 271 浏览 2 评论 0原文

我的网页中有一个宽度为 0 的 div,其左右边框各为 1px 宽度。

在 Firefox 中,当我给出以下代码时,它保存宽度为 50px 的 div,但在 IE7 中它恰好是 48px 宽。

<div style="width: 48px; border: #a9a9a9 1px solid; height: 30px;">test div</div>

谁能帮我解决这个问题?

提前致谢。

Im my web page there is a div with width 0 which has a left and right border of 1px width each.

In Firefox when I give the following code it holds the div with 50px width, but it happens to be 48px wide in IE7.

<div style="width: 48px; border: #a9a9a9 1px solid; height: 30px;">test div</div>

Can anyone help me resolving this issue?

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

第七度阳光i 2024-08-03 22:38:17

看起来像 IE 框模型错误。 如果在 Quirks 模式下,IE 会从元素宽度中减去边框、填充、边距。 请参见下图:

如果您为 HTML 声明了正确的 DOCTYPE,则此问题应该会消失。

Looks like IE box model bug. If in Quirks mode, IE subtracts border, padding, marginfrom element width. See the diagram below:

If you declare correct DOCTYPE for your HTML, this problem should go away.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文