浏览器之间的 HTML 表格边框颜色差异很大

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12511228/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 02:54:46  来源:igfitidea点击:

HTML Table BorderColor differs dramatically between browsers

htmlcsshtml-tablecross-browser

提问by Digital Lightcraft

I have a bit of an annoying issue whereby my tables seem to be appearing completely differently between browsers, they are set as:

我有一个烦人的问题,我的表格在浏览器之间似乎完全不同,它们被设置为:

<table width="100%" border="1" cellpadding="4"  cellspacing="0" bordercolor="#eeeeee">

So the left one (Chrome) is correct at #eeeeee, but FF and IE just seem to be making it up as they go along!! There is nothing in my CSS that is event vaguely close to specifying a table border (I even tried un-linking my CSS files and the issue remained)

所以左边的(Chrome)在#eeeeee 是正确的,但 FF 和 IE 似乎只是在他们进行时弥补!!我的 CSS 中没有任何东西与指定表格边框模糊接近(我什至尝试取消链接我的 CSS 文件,但问题仍然存在)

Any ideas?

有任何想法吗?

enter image description here

在此处输入图片说明

回答by Kootsj

@Darkat Studios

<table width="100%" border="1" cellpadding="4" cellspacing="0" style="border: 2px solid #eeeeee;">- now there IS indeed a light grey border, HOWEVER the cells are all still black outlined.. VERY odd! –

@Darkat 工作室

<table width="100%" border="1" cellpadding="4" cellspacing="0" style="border: 2px solid #eeeeee;">- 现在确实有一个浅灰色边框,但是单元格仍然是黑色的轮廓......非常奇怪!——

you should remove the border="1"

你应该删除 border="1"

回答by Henrik Ammer

Try this CSS

试试这个 CSS

table{
    border-collapse: collapse;
    border: 1px solid #eee;
    width: 100%;
}
table th,
table td
{
    padding: 4px;
}

And change your HTML to simply state

并将您的 HTML 更改为简单说明

<table>

回答by Praveen Kumar Purushothaman

Give that in CSS:

在 CSS 中给出:

table {border: 2px solid #eeeeee;}

Or at least:

或者至少:

table {border-style: solid;}

Now check in all the browsers.

现在检查所有浏览器。

回答by Jukka K. Korpela

Yes, the implementation of the nonstandard attribute bordercolorvaries across browsers. It even depends on browser mode (Standards vs. Quirks mode).

是的,非标准属性的实现bordercolor因浏览器而异。它甚至取决于浏览器模式(标准模式与怪癖模式)。

You can make the situation more consistent by setting, in CSS, all border properties on the tableelement andits cells. Or you could style the table and its cells in CSS only.

您可以通过设置情况较为一致,在CSS中,所有的边框属性table元素它的细胞。或者您可以仅在 CSS 中设置表格及其单元格的样式。

回答by M.Bz

Try remove the '#' bordercolor="eeeeee"

尝试删除 '#' bordercolor="eeeeee"