Reputation: 567
This is what I am trying to achieve (Firebase dashboard). I would like to separate each row of my table with tiny lines.
I am using border: 1px solid rgb(212, 206, 206)
for my table tr and the result is very different. My line separator between each rows is bigger. What should I do to make the border tinier?
dashboard.js
<table>
<tr>
<th>Email</th>
<th>Registration Date</th>
<th>Status</th>
<th>Other</th>
</tr>
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
</table>
dashboard.css
.dashboard-content table{
width: 100%;
border-collapse: collapse;
}
table tr{
border: 1px solid rgb(212, 206, 206);
}
Upvotes: 0
Views: 68
Reputation: 2255
My suggestion:
table {
width: 100%;
border-collapse: collapse;
}
table tr {
border-bottom: 1px solid rgb(212, 206, 206);
text-align: center;
}
tr:nth-child(odd) {
background-color: rgb(238,238,238);
}
table th,
table td {
padding: 5px;
}
<table>
<tr>
<th>Email</th>
<th>Registration Date</th>
<th>Status</th>
</tr>
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
<td>21</td>
</tr>
</table>
Upvotes: 1
Reputation: 20699
Instead of assigning borde all around, you could just assign border-top
so 1px
will not actually looks like 2px:
table tr {
border-top: 1px solid rgba(212, 206, 206, 0.5);
}
Also If you want the table itself has some border as well, you can do it like this:
table {
border: 1px solid rgba(212, 206, 206, 0.5);
}
table tr:not(:first-child) {
border-top: 1px solid rgba(212, 206, 206, 0.5);
}
Here's the full example:
table {
border-collapse: collapse;
border: 1px solid rgba(212, 206, 206, 0.5);
width: 100%;
text-align: center;
}
table tr:not(:first-child) {
border: 1px solid rgba(212, 206, 206, 0.5);
}
/* for decoration */
table tr:nth-child(2n) {
background-color: rgba(0, 0, 0, 0.01);
}
<table>
<tr>
<th>Email</th>
<th>Registration Date</th>
<th>Status</th>
<th>Other</th>
</tr>
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
<td></td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
<td></td>
</tr>
<tr>
<td>Bob</td>
<td>Ross</td>
<td>70</td>
<td></td>
</tr>
</table>
Upvotes: 2
Reputation: 3267
You are setting the border all round, but I think it's more of a trick of the eye. Try this to make it lighter in colour
table tr{
border: 1px solid rgba(212, 206, 206, 0.5);
}
Also, making the background gray won't make the border look so striking and thick
Upvotes: 2