Html 如何指定 <tr> 的底部边框?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1384823/
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
How to specify the bottom border of a <tr>?
提问by omg
I tried :
我试过 :
.bb {
border-bottom:1px;
}
<tr class="bb">
But no effect at all.
但是完全没有效果。
回答by David Andres
Try the following instead:
请尝试以下操作:
<html>
<head>
<title>Table row styling</title>
<style type="text/css">
.bb td, .bb th {
border-bottom: 1px solid black !important;
}
</style>
</head>
<body>
<table>
<tr class="bb">
<td>This</td>
<td>should</td>
<td>work</td>
</tr>
</table>
</body>
</html>
回答by Suciu Lucian
Add border-collapse:collapse
to the table.
添加border-collapse:collapse
到表中。
Example:
例子:
table.myTable{
border-collapse:collapse;
}
table.myTable tr{
border:1px solid red;
}
This worked for me.
这对我有用。
回答by Eran Betzalel
You should define the style on the td
element like so:
您应该td
像这样定义元素的样式:
<html>
<head>
<style type="text/css">
.bb
{
border-bottom: solid 1px black;
}
</style>
</head>
<body>
<table>
<tr>
<td>
Test 1
</td>
</tr>
<tr>
<td class="bb">
Test 2
</td>
</tr>
</table>
</body>
</html>
回答by JD - DC TECH
tr td
{
border-bottom: 2px solid silver;
}
or if you want the border inside the TR tag, you can do this:
或者如果你想要 TR 标签内的边框,你可以这样做:
tr td {
box-shadow: inset 0px -2px 0px silver;
}
回答by Halt
What I want to say here is like some kind of add-on on @Suciu Lucian's answer.
我想在这里说的是@Suciu Lucian 回答的某种附加内容。
The weird situation I ran into is that when I apply the solution of @Suciu Lucian in my file, it works in Chrome but not in Safari (and did not try in Firefox). After I studied the guide of styling table borderpublished by w3.org, I found something alternative:
我遇到的奇怪情况是,当我在我的文件中应用 @Suciu Lucian 的解决方案时,它在 Chrome 中有效,但在 Safari 中无效(并且没有在 Firefox 中尝试)。在我研究了w3.org 发布的表格边框样式指南后,我发现了一些替代方法:
table.myTable{
border-spacing: 0;
}
table.myTable td{
border-bottom:1px solid red;
}
Yes you have to style the td
instead of the tr
.
是的,您必须设置样式td
而不是tr
.