I’ve created the table, but where 2 cells meet, the border is darker and thicker. How can I solve this issue? Here’s my CSS code.
.custom-table-2 {
border-collapse: separate;
/*border-collapse: collapse;*/
border-spacing: 0;
}
.custom-table-2 td {
border: 1px solid #00953B;
}
.custom-table-2 tr:first-child td:first-child {
border: 0px;
}
.custom-table-2 tr:nth-child(2) td:first-child {
border-top-left-radius: 16px;
}
.custom-table-2 tr:first-child td:nth-child(2) {
border-top-left-radius: 16px;
}
.custom-table-2 tr:first-child td:last-child {
border-top-right-radius: 16px;
}
.custom-table-2 td:nth-child(2) {
background-color: #7CCB99;
}
If I use ‘border-collapse: collapse;’, it won’t be thicker, but then the border radii won’t show. Any ideas for a solution?
2
Answers
If you have a table with borders that overlap each other and you want to remove the overlapping borders using CSS, you can try a few different approaches. Here are two common methods:
CSS provides a property called
border-collapse
which controls whether the borders of table cells should be collapsed into a single border or separated. To remove overlapping borders, you can set this property tocollapse
.By using
border-collapse: collapse;
, adjacent cell borders will be collapsed into a single border, effectively removing any overlapping borders.If you want more control over each cell’s border, you can apply individual border styles to each cell.
By setting the border style individually for each cell, you can prevent overlapping borders and style them as needed.
Remember that these approaches are meant to address common scenarios where table borders overlap. Depending on your specific situation and CSS rules, you may need to adjust these solutions to suit your needs.
Set individual borders for
<td>
, not shorthand: