在 HTML 中设置内部表格边框
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2658260/
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
Set inner table border in HTML
提问by ripper234
How do I set the "inner border" - the border between different cells.
如何设置“内边框” - 不同单元格之间的边框。
By setting style attributes I manage to control the outer border, but the inner border just stays the same gray color and the same width. What attributes should I tweak to control the inner border?
通过设置样式属性,我设法控制了外边框,但内边框只是保持相同的灰色和相同的宽度。我应该调整哪些属性来控制内边框?
回答by dalgard
For ordinary table markup, here's a short solution that works on all devices/browsers on BrowserStack, except IE 7 and below:
对于普通表格标记,这里有一个简短的解决方案,适用于 BrowserStack 上的所有设备/浏览器,IE 7 及以下版本除外:
table { border-collapse: collapse; }
td + td,
th + th { border-left: 1px solid; }
tr + tr { border-top: 1px solid; }
For IE 7 support, add this:
对于 IE 7 支持,添加以下内容:
tr + tr > td,
tr + tr > th { border-top: 1px solid; }
A test case can be seen here: http://codepen.io/dalgard/pen/wmcdE
可以在这里看到一个测试用例:http: //codepen.io/dalgard/pen/wmcdE