Is it possible to convert a horizontal table to a vertical one using only CSS?
Here's what I have:
1st header cell | 2nd header cell | 3rd header cell | 4th header cell |
---|---|---|---|
1st data cell | 2nd data cell | 3rd data cell | 4th data cell |
Here's what I want:
1st header cell | 1st data cell
2nd header cell | 2nd data cell
3rd header cell | 3rd data cell
4th header cell | 4th data cell
My code:
table{
width: 100%;
border-collapse: collapse;
}
td, th {
text-align: left;
border: 1px solid #ddd;
padding: 10px;
}
<table>
<tbody>
<tr>
<th>1st header cell</th>
<th>2nd header cell</th>
<th>3rd header cell</th>
<th>4th header cell</th>
</tr>
<tr>
<td>1st data cell</td>
<td>2nd data cell</td>
<td>3rd data cell</td>
<td>4th data cell</td>
</tr>
</tbody>
</table>