[英]Table border adding 1px in the corner of each TD
I have a table that when I use border-collapse:collapse;
我有一张桌子,当我使用
border-collapse:collapse;
it shows a single 1px in the border of the row coming from the following row. 它在来自下一行的行的边框中显示单个1px。 Any ideas how I can fix that?
我有什么想法可以解决这个问题吗?
I want it to look exactly like that without any padding between the cells or anything. 我希望它看起来完全没有在单元格或任何东西之间没有任何填充。
This is in Firefox by the way, I haven't tried other browsers. 这是在Firefox的方式,我没有尝试过其他浏览器。
Here is my JSFiddle. 这是我的JSFiddle。
HTML / CSS HTML / CSS
.responsive-table { border-collapse: collapse; width: 100%; } .responsive-table td { border: 1px solid #ddd; } .responsive-table tbody tr:nth-of-type(2n) { background: #f7f7f7; } .responsive-table tbody tr:nth-of-type(2n+1), .resp-content, .resp-div { background: #eee; } .responsive-table thead th, .basic-table thead th { background: #006bb2; color: #fff; } .responsive-table th { border: 1px solid #0087e0; }
<table class="responsive-table"> <thead> <tr> <th>H</th> <th>H</th> <th>H</th> <th>H</th> <th>H</th> <th>H</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>1</td> <td>1</td> <td>1</td> <td>1</td> <td>1</td> </tr> <tr> <td>2</td> <td>2</td> <td>2</td> <td>2</td> <td>2</td> <td>2</td> </tr> </tbody> </table>
Just increase the lower border width of the table header: 只需增加表头的下边框宽度:
.responsive-table th {
border: 1px solid #0087e0;
border-bottom-width: 2px;
}
.responsive-table { border-collapse: collapse; width: 100%; } .responsive-table td { border: 1px solid #ddd; } .responsive-table tbody tr:nth-of-type(2n) { background: #f7f7f7; } .responsive-table tbody tr:nth-of-type(2n+1), .resp-content, .resp-div { background: #eee; } .responsive-table thead th, .basic-table thead th { background: #006bb2; color: #fff; } .responsive-table th { border: 1px solid #0087e0; border-bottom-width: 2px; }
<table class="responsive-table"> <thead> <tr> <th>H</th> <th>H</th> <th>H</th> <th>H</th> <th>H</th> <th>H</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>1</td> <td>1</td> <td>1</td> <td>1</td> <td>1</td> </tr> <tr> <td>2</td> <td>2</td> <td>2</td> <td>2</td> <td>2</td> <td>2</td> </tr> </tbody> </table>
Alternatively, border-bottom-style: double;
或者,
border-bottom-style: double;
will specify, as the name suggests, a double border: 顾名思义,它将指定一个双边框:
.responsive-table th {
border: 1px solid #0087e0;
border-bottom-style: double;
}
.responsive-table { border-collapse: collapse; width: 100%; } .responsive-table td { border: 1px solid #ddd; } .responsive-table tbody tr:nth-of-type(2n) { background: #f7f7f7; } .responsive-table tbody tr:nth-of-type(2n+1), .resp-content, .resp-div { background: #eee; } .responsive-table thead th, .basic-table thead th { background: #006bb2; color: #fff; } .responsive-table th { border: 1px solid #0087e0; border-bottom-style: double; }
<table class="responsive-table"> <thead> <tr> <th>H</th> <th>H</th> <th>H</th> <th>H</th> <th>H</th> <th>H</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>1</td> <td>1</td> <td>1</td> <td>1</td> <td>1</td> </tr> <tr> <td>2</td> <td>2</td> <td>2</td> <td>2</td> <td>2</td> <td>2</td> </tr> </tbody> </table>
More information: Border conflict resolution 更多信息: 边界冲突解决方案
Use pseudo-elements to cover it up: 使用伪元素来掩盖它:
.responsive-table thead th:after {
width: 0;
height: 0;
content: '';
position: absolute;
right: 0;
bottom: 0;
border-left: 1px solid #0087e0;
}
Just change the color of the border to whatever matches. 只需将边框的颜色更改为任何匹配项。 You could also use a
:before
to cover up the far left side's blemish. 您也可以使用
:before
掩盖最左侧的瑕疵。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.