[英]How to add border between td's in which are in different tr's?
To simplify my problem I wrote the below html and css to give an overview. 为了简化我的问题,我写了下面的html和css来进行概述。 I want to add border between A/C and B/D.
我想在A / C和B / D之间添加边框。 How can I do that ?
我怎样才能做到这一点 ? If I am not clear on my question then please let me know.
如果我不清楚我的问题,请告诉我。 Thanks.
谢谢。
table.test { border-collapse: separate; border-spacing: 10px; width: 100%; } .tdLeft { vertical-align: top; width: 390px; } .tdRight { padding-left: 4px; width: 390px; vertical-align: top; border-left: solid; border-width: 1px }
<table class="test"> <tr> <td class="tdLeft"> <td>A</td> <td>B</td> </td> </tr> <tr> <td class="tdRight"> <td>C</td> <td>D</td> </td> </tr> </table>
First of all, you need to remove the td tags that surround the td with data in them. 首先,您需要删除围绕td的td标签,其中包含数据。 td aren't nested.
td没有嵌套。 If you want to assign a class that will apply to all td in a given tr, then assign the class to the tr.
如果要分配适用于给定tr中所有td的类,请将该类分配给tr。
Now to add the border: we can do this with simple CSS, along with adding a class to your html: 现在添加边框:我们可以使用简单的CSS来做到这一点,并为您的html添加一个类:
<table class="test">
<tr class="firstRow">
<td>A</td>
<td>B</td>
</tr>
<tr>
<td>C</td>
<td>D</td>
</tr>
</table>
The following CSS gives you two distinct lines - one beneath A, one beneath B. 以下CSS为您提供了两条截然不同的行-A在A下,B在B下。
table.test {
border-collapse: separate;
border-spacing: 10px;
width: 100%;
}
.tdLeft {
vertical-align: top;
width: 390px;
}
.tdRight {
padding-left: 4px;
width: 390px;
vertical-align: top;
}
.firstRow td {
border-bottom: 1px solid red;
}
If you want to have a single continuous line beneath the two cells (underline the entire row), you need to adjust other parts of your CSS - remove the border-spacing, and set border-collapse to collapse: 如果要在两个单元格下面有一条连续线(在整行下划线),则需要调整CSS的其他部分-删除border-spacing,并将border-collapse设置为塌陷:
table.test {
border-collapse: collapse;
width: 100%;
}
.tdLeft {
vertical-align: top;
width: 390px;
}
.tdRight {
padding-left: 4px;
width: 390px;
vertical-align: top;
}
.firstRow td {
border-bottom: 1px solid red;
}
I dont know why are you adding <td> inside another <td> 我不知道为什么要在另一个<td>中添加<td>
Instead you can do 相反,你可以做
<table class="test">
<tr class=row>
<td>A</td>
<td>B</td>
</tr>
<tr>
<td>C</td>
<td>D</td>
</tr>
</table>
css 的CSS
tr:nth-child(1)>td{
border-bottom:1px solid #CCC;
}
table.test{
border-collapse: collapse;
width: 100%;
}
You can use table-border=1px; 您可以使用table-border = 1px; Simple !
很简单!
Maybe something like this will do the trick: 也许这样的事情可以解决问题:
html html
<table class="test">
<tr>
<td>
<td class="tdLeft">A</td>
<td>B</td>
</td>
</tr>
<tr>
<td>
<td class="tdRight">C</td>
<td>D</td>
</td>
</tr>
</table>
css: CSS:
table.test {
border-collapse: separate;
border-spacing: 10px;
width: 100%;
}
.tdLeft {
vertical-align: top;
border-bottom: 1px solid;
width: 390px;
}
.tdRight {
padding-left: 4px;
width: 390px;
vertical-align: top;
border-left: solid;
border-width: 1px;
border-bottom: 1px solid;
}
http://jsfiddle.net/n197somp/1/ http://jsfiddle.net/n197somp/1/
我猜你可以像这样<table class="test" border=1px>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.