在 HTML 中设置内部表格边框

发布于 2024-08-29 17:43:12 字数 91 浏览 2 评论 0原文

如何设置“内边框”——不同单元格之间的边框。

通过设置样式属性,我设法控制外边框,但内边框仅保持相同的灰色和相同的宽度。我应该调整哪些属性来控制内边框?

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?

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

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

发布评论

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

评论(2

往日情怀 2024-09-05 17:43:12

对于普通的表格标记,这里有一个简短的解决方案,适用于 BrowserStack 上的所有设备/浏览器(IE 7 及以下版本除外):

table { border-collapse: collapse; }

td + td,
th + th { border-left: 1px solid; }
tr + tr { border-top: 1px solid; }

对于 IE 7 支持,请添加以下内容:

tr + tr > td,
tr + tr > th { border-top: 1px solid; }

可以在此处查看测试用例: http://codepen.io/dalgard/pen/wmcdE

For ordinary table markup, here's a short solution that works on all devices/browsers on BrowserStack, except IE 7 and below:

table { border-collapse: collapse; }

td + td,
th + th { border-left: 1px solid; }
tr + tr { border-top: 1px solid; }

For IE 7 support, add this:

tr + tr > td,
tr + tr > th { border-top: 1px solid; }

A test case can be seen here: http://codepen.io/dalgard/pen/wmcdE

在风中等你 2024-09-05 17:43:12

您需要设置 元素的样式。

查看 W3C 网站

You need to style the <td> element.

Take a look at the W3C website

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