Firefox 上的 CSS 问题,边框无法正确显示

发布于 2024-08-03 12:22:03 字数 370 浏览 5 评论 0原文

我在 Firefox 上遇到问题,而所有 IE、Safari 和 Chrome 都可以正常工作。

<div class="forDiv">ddd</div>
<table class="forTable"> .... </table>


.forDiv {
width:100%;
border:3px solid #236FBD;
background-color: #236FBD;
}

.forTable{
width:100%;
border:3px solid #236FBD;
background-color: #236FBD;
}

在 Firefox 中,div 稍小一些。我该如何修复它?

i got an issue on firefox, while all IE, Safari and chrome are working.

<div class="forDiv">ddd</div>
<table class="forTable"> .... </table>


.forDiv {
width:100%;
border:3px solid #236FBD;
background-color: #236FBD;
}

.forTable{
width:100%;
border:3px solid #236FBD;
background-color: #236FBD;
}

in firefox, the div is a bit smaller. how can i fix it?

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

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

发布评论

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

评论(5

别闹i 2024-08-10 12:22:03
.forDiv {
width:100%;
border:3px solid #236FBD;
background-color: #236FBD;
-moz-box-sizing: border-box;
}

.forTable{
width:100%;
border:3px solid #236FBD;
background-color: #236FBD;
-moz-box-sizing: border-box;
}
.forDiv {
width:100%;
border:3px solid #236FBD;
background-color: #236FBD;
-moz-box-sizing: border-box;
}

.forTable{
width:100%;
border:3px solid #236FBD;
background-color: #236FBD;
-moz-box-sizing: border-box;
}
南冥有猫 2024-08-10 12:22:03

不同浏览器处理宽度属性的方式不一致 - 它们是否在宽度中包含边框/填充尺寸,或者是否认为它们是额外的。

您可以使用设置为“border-box”的 -moz-box-sizing 属性来告诉基于 Mozilla 的浏览器模拟 IE 在怪异模式下的操作方式(请参阅 此页面了解详细信息)。

It's an inconsistency in how different browsers treat the width attribute - whether they include the border/padding dimensions in the width, or whether they consider them additional.

You can use the -moz-box-sizing attribute set to "border-box" to tell Mozilla-based browsers to emulate how IE does it in quirks mode (see this page for details).

久隐师 2024-08-10 12:22:03

尝试溢出:隐藏;
我也有同样的问题。然后我得到了这个

链接

来自我的 得到解决方案。使 div 的溢出:隐藏,它对我来说效果很好。

Try overflow:hidden;
i also had same problem. then i got this

link

from that i got soln. to make div's overflow:hidden and it worked fine for me.

月亮坠入山谷 2024-08-10 12:22:03

最有可能与相邻或包含元素中设置的边距或填充有关。如果没有完整的上下文,很难判断,但也可以尝试设置 div 和表格的边距和填充属性,看看会发生什么。

Most likely has something to do with the margins or padding set in neighboring or containing elements. Hard to tell without the full context but also try setting the margin and padding attributes for the div and table and see what happens.

北座城市 2024-08-10 12:22:03

好吧,这似乎是经典的 IE 盒子模型不一致(或者我应该说,bug?)

最简单的解决方法是在容器 div 中定义 div(包含 ddd 的那个),如下所示:

<div id="container">
  <div class="forDiv">ddd</div>
</div>

并定义 CSS 属性如下所示:

#container
{
  width:100%;
}

.forDiv
{
  border: 3px solid;
}

这应该在 IE 和 Gecko 中提供相同的大小。

Ok, this appears to be the classic IE box-model inconsistency (or shall I say, bug?)

The simplest way around it is to define your div (the one containing ddd) inside a container div like this:

<div id="container">
  <div class="forDiv">ddd</div>
</div>

And define the CSS properties as follows:

#container
{
  width:100%;
}

.forDiv
{
  border: 3px solid;
}

This should give you the same size in both IE and Gecko.

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