Html 外边框为黑色,内边框为灰色的表格

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2652777/
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:45:31  来源:igfitidea点击:

Table with black outer, but grey inner border

htmlcsshtml-tableborder

提问by AGuyCalledGerald

I want to create a html table with a 1pt black outer border and the same border around every td.

我想创建一个带有 1pt 黑色外边框和每个 td 周围相同边框的 html 表。

Should look like this (only the borders, of course)

应该是这样的(当然只有边框)

enter image description here

在此处输入图片说明

I use

我用

<table border="1" style="border-collapse:collapse; border-color:Black; border-style:solid; border-width:1pt">

As a result I get a black outer, but grey inner borders.

结果,我得到了一个黑色的外边框,但灰色的内边框。

回答by Kyle

You could try implement something like this in your CSS stylesheet.

您可以尝试在 CSS 样式表中实现类似的内容。

.mytable
{
border-collapse:collapse; 
border-color:#000000; 
border-style:solid; 
border-width:2px;
}

.mytable td
{
border-color:#cccccc; /*grey*/
border-style:solid; 
border-width:1px;
}

And something like this HTML:

像这样的 HTML:

<table class="mytable">
    <tr>
        <td>Content</td>
    </tr>
</table>

Example here

示例在这里