My border radius does not show if I have the property of border-collapse on the table tag. I need the border-radius property on and if I remove the border-collapse property I don't get the look I want which is the grey sections to go to the very edge of the table.
What is the solution to this and whats the cause of it?
Thanks in advance
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
table {
/*if i comment out the border-collapse property it then shows my radius*/
border-collapse: collapse;
margin: 25px 0;
width: 50%;
border-radius: 5px;
font-size: 1.4rem;
min-width: 400px;
border: 1px solid #c3c3c3;
/*margin is just for demo*/
margin: 20px 20px;
}
table tr {
border-bottom: solid 1px #d1d1d1;
}
table tr:nth-child(odd) {
background-color: #eee;
}
table td {
padding: 10px 15px;
}
table td:first-of-type {
font-weight: 600;
}
<table>
<tbody>
<tr>
<td>Application</td>
<td>Natural gas & LPG</td>
</tr>
<tr>
<td>Standards</td>
<td>BS EN ISO 9001:2008 - EN 331:1998</td>
</tr>
<tr>
<td>Connection</td>
<td>BSP Taper F</td>
</tr>
<tr>
<td>Finish</td>
<td>Plated</td>
</tr>
</tbody>
</table>
very
If your intention is to not see any spacing between the content background and the border, then simply remove the
border-collapse
and addborder-spacing: 0
.border-spacing: 0
will not affect the border radius at all and it will also give you the results of no space between the border and the inner content.In searching it seems there are some anomalies with using collapse and radius together. There are also some work arounds where you use psuedo tags on the tables children specifically to get a radius to work, but why waste all that time when you can just remove the space between the border and its inner content using
border-spacing
which works well withborder-radius
EDIT: By using psuedo selectors along with
border-space: 0
you can achieve a more pronounced border radius.We want to target each td element that borders the edge of the table element.
table tr td:first-of-type
andtable tr td:last of type
to get the left and right sides. Then we target each subsequent first and last child to get the corners. Lastly, if this is a dynamic table and you will have more thantwo
data tables located in the table, addtd:not(:first-child):not(:last-child)
on each first and last of type.I don't get the look I want which is the grey sections to go to the very edge of the table.