为什么 Firefox 缺少某些 HTML 表格的边框
我使用的是 Firefox 3.5.7,并且在多个 HTML 表格中使用了相同的 CSS,但在某些示例中,部分边框未显示。
对我来说毫无意义的是,同一页面上另一个 HTML 表的相同 CSS 工作正常。此外,从边框的角度来看,Internet Explorer 中的同一页面看起来也很好。
这是带有示例的图像,正如您在本例中看到的那样,第一个表格的底部缺少边框。
有谁知道为什么会在这里发生这种情况吗?
I am using Firefox 3.5.7 and I have the same CSS used in multiple HTML tables, but there are some examples where parts of the borders are not shown.
What makes no sense to me is that the same CSS on the same page for another HTML table works fine. Also, the same page in Internet Explorer looks fine from a border point of view.
Here is an image with an example, as you can see in this case the bottom of the first table is missing a border.
Does anyone have a clue why this would happen here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
也许您放大/缩小了一点。当您执行 Ctrl+滚轮操作时,可能会意外或故意发生这种情况。也许它没有完全重置为缩放级别零。这种错误渲染行为在某些网站上是可以识别的,在 SO 也是如此。
要解决此问题,只需按 Ctrl+0 或执行 View > 缩放 > 重置将缩放级别重置为默认值。
这是 Firefox/Gecko 错误 410959。这会影响带有
border-collapse:collapse
的表。这是 2008 年的事情,目前还没有真正的进展,因此您可能需要找到解决方法。一种方法是使用 border-collapse:separate 并在每个单元格的基础上调整边框。Maybe you've zoomed in/out a bit. This can happen either accidently or knowingly when you do Ctrl+Scrollwheel. Maybe it isn't completely resetted to zoom level zero. This mis-rendering behaviour is then recognizeable at some websites, also here at SO.
To fix this, just hit Ctrl+0 or do View > Zoom > Reset to reset the zoom level to default.
This is Firefox/Gecko bug 410959. This affects tables with
border-collapse:collapse
. It's from 2008 and there's no real progress on it, so you'll probably need to find a workaround. One way is usingborder-collapse:separate
and fiddling with borders on a per-cell basis.当我在我正在开发的应用程序上缩小 Firefox 时,我发现了类似的问题。
主要原因是 CSS
border-collapse
属性设置为collapse
。将其更改为
单独
反而解决了问题。然而,这意味着我必须重新考虑将边框应用于表格各个部分的方式,因为否则您的边框的厚度会增加一倍。我最终不得不使用 jQuery 为每个tr
中的最后一个td
或th
以及最后一个提供特殊的“last”类表中的tr
。我的查询类似于:我的 CSS 规则类似于:
我最终使用了浏览器定位,因此我只将这些规则应用于 Firefox 用户,但它可能适用于所有浏览器,我还没有测试过。
I found a similar problem when zoomed out in Firefox on an application I am working on.
The main cause was having the CSS
border-collapse
property set tocollapse
.Changing it to
separate
instead fixed the problem. However, that meant I did have to rethink the way borders are applied to various parts of the table, because otherwise your borders will appear to double in thickness. I ended up having to use jQuery to give a special "last" class to the lasttd
orth
in eachtr
, and to the lasttr
in the table. My query was something like:My CSS rules were similar that:
I did end up using browser targeting so that I only applied these rules to Firefox users, but it may work for all browsers, I haven't tested.
这是由于表格(缺少底部边框)位于 div 内而导致的...边框显然没有在表格高度中计算,因此边框在那里但未显示。
给周围的 div 一个从 1px 开始的 margin-bottom 解决了这个问题。
This was caused by the table (with a missing bottom-border) to be inside a div...The border apparently didn't get calculated in the table height, so the border was there but wasn't shown.
Giving the surrounding div a margin-bottom from 1px solved the problem.
基于@GregL 的良好答案(我似乎无法直接对其进行“评论”):
我没有使用 JQuery 生成“最后一个”类,而是简单地使用了内置的伪元素选择器
:first-child
。我构建了选择tr:first-child
和td:first-child
的规则,定义了border-top
和border-left (而不是 GregL 的答案中的
border-right
和border-bottom
)。通用规则定义border-right
和border-bottom
,而不是border-left
和border-top
。:first-child
据说在 Chrome v 中受支持 4.0、Firefox v.3.0、IE 7.0、Safari v.3.1 和 Opera v.9.6 ()。在 Firefox v. 40.0.3 上进行了测试,我首先在其中看到了这个问题。Building on the good answer of @GregL (I seem unable to "comment" directly on it):
Instead of using JQuery to generate a "last" class, I simply used the built-in pseudo-element selector
:first-child
. I built rules selectingtr:first-child
andtd:first-child
that defineborder-top
andborder-left
(instead ofborder-right
andborder-bottom
as in GregL's answer). The generic rules defineborder-right
andborder-bottom
instead ofborder-left
andborder-top
.:first-child
is said to be supported in Chrome v. 4.0, Firefox v. 3.0, IE 7.0, Safari v. 3.1, and Opera v. 9.6 (). Tested on Firefox v. 40.0.3, where I saw this problem in the first place.只需使用
border-spacing:0;
希望这能解决您的问题。Just use
border-spacing:0;
hope this will solve your problem.当浏览器缩放增加时,边框开始消失。我能够通过执行以下操作来解决它。在 Chrome 和 Firefox 中测试。
Border started going missing when browser zoom was increased. I was able to solve it by doing the following. Tested in Chrome and Firefox.
我也遇到了同样的问题,缺少表格边框。
我的解决方案是:
表格行的边框:
我在布局中使用 Bootstrap,并且表格也有 Bootstrap css 类,例如“table table-striped table-bordered”
这个解决方案对我有用,当我尝试了解决方案,但
它对我来说不能正常工作。
I had the same problem with missing table border.
My solution is:
And border for table rows:
I am using Bootstrap either in my layout and the table has also bootstrap css classes like "table table-striped table-bordered"
This solution works for me, when I tried solution with
it didn't work properly for me.
为我实现答案@Donald Payne
*(.table - bootstrap class)
worked for me realisation of answer @Donald Payne
*( .table - bootstrap class )
这有点离题,但对于那些在 Firefox 中搜索缺失边框的人来说……
我有一个表格行 (
) 的边框底部,在设置背景的地方缺失了一个特定的细胞。事实证明,这是由单元格上的恶意
position:relative
引起的,删除它(或将其更改为position:inherit
)修复了它。Firefox 70.0.1
This is a bit tangential, but for those searching for missing borders in Firefox…
I had a border-bottom of a table-row (
<tr>
) that was missing where a background had been set on a specific cell. It turned out this was caused by a rogueposition: relative
on the cell, removing that (or changing it toposition: inherit
) fixed it.Firefox 70.0.1