Im having trouble making a valid HTML table with vertical spacing between rows and shadow below each row.
The shadow always goes on top of other table data.
I have positioned the elements and set a z-index.
table {
border-collapse: separate;
border-spacing: 0;
}
td,
th {
min-width: 170px;
}
.shadow {
position: relative;
z-index: 1;
margin: 2px 0 2px 0;
}
.shadow:before {
content: "";
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
z-index: -1;
box-shadow: 0 0 10px 10px #000;
}
<main>
<table>
<thead>
<tr>
<td>head</td>
<td>head</td>
<td>head</td>
</tr>
</thead>
<tbody>
<tr>
<td><div class="shadow">div</div></td>
<td><div class="shadow">div</div></td>
<td><div class="shadow">div</div></td>
</tr>
<tr>
<td><div class="shadow">div</div></td>
<td><div class="shadow">div</div></td>
<td><div class="shadow">div</div></td>
</tr>
<tr>
<td><div class="shadow">div</div></td>
<td><div class="shadow">div</div></td>
<td><div class="shadow">div</div></td>
</tr>
</tbody>
<tfoot>
<tr>
<td>foot</td>
<td>foot</td>
<td>foot</td>
</tr>
</tfoot>
</table>
</main>
2
Answers
One approach is as below, with explanatory comments in the code itself:
You can do this like.