I want to put a background color on a whole <tr>
. I tries it, and got white gaps between cells. I found many answers like this suggesting collapsing the table's borders. However, I don't want the borders collapsed! I want the borders on all other rows, just no on this one colored row (or more accurately, I want the spacing of the borders even in this row, but the BG color should include the spacing)
Here is the fiddle: http://jsfiddle.net/qEg9L/1/ . As you can see, the rest of the table's cells are various colors, and the border helps to distinguish them. Only the top row is a solid color, and I don't want the borders
Use border-collapse: collapse;
but then add your own border
EDIT (now that you posted your fiddle)
table{
border-collapse: collapse;
}
table td{
border: 1px solid white;
}
<table>
<tr class="withBack">
<td>test</td>
<td>test</td>
</tr>
<tr>
<td>test</td>
<td>test</td>
</tr>
</table>
table{
border-collapse: collapse;
}
table td{
border: 5px solid green;
padding: 10px 20px;
}
.withBack
{
background: pink;
}
.withBack td
{
background: pink;
border: 5px solid pink;
}
添加一个css文件以仅对td标签着色,然后您将能够看到边框。
just add this style to table like this
<table style='border-spacing:0px'>
// your code.
</table>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.