JSFiddle - React, Tailwind, and code Playground
by Torwan
HTML
<table class="mytable">
<thead>
<tr>
<th>ID.</th>
<th>Name</th>
<th>Code</th>
<th>Phone</th>
<th>Email</th>
<th>Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Jan Kowal</td>
<td>111101</td>
<td>+48 222 333 444</td>
<td>[email protected]</td>
<td>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum euismod tortor auctor sem dictum, ac euismod tortor gravida. Suspendisse sed tristique ipsum. </td>
</tr>
<tr>
<td>2</td>
<td>Janina Kowalska</td>
<td>2222201</td>
<td>+48 222 555 888</td>
<td>[email protected]</td>
<td>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum euismod tortor auctor sem dictum, ac euismod tortor gravida. Suspendisse sed tristique ipsum. </td>
</tr>
</tbody>
</table>
CSS
.table-responsive {
display: block;
width: 100%;
overflow-x: auto;
-webkit-overflow-scrolling: touch;
word-wrap: break-word;
white-space: nowrap;
}
.table {
width: 100%;
}
table.mytable {
margin: 0 auto;
border-collapse: collapse;
width: 100%;
background: #fff;
}
table.mytable thead th {
padding: 15px 10px;
font-size: 15px;
color: #797777;
border-bottom: 2px solid #2f2b68;
font-weight: normal;
word-wrap: break-word;
white-space: nowrap;
font-weight: 500;
text-align: left;
background: #333;
}
table.mytable tbody td {
padding: 15px 10px;
font-size: 14px;
color: #858585;
font-weight: normal;
border-bottom: 1px solid #dcdcdc;
}
table.mytable tbody td > a > a {
color: #333;
text-decoration: none;
}
table.mytable tbody tr:nth-child(odd){
background: #fff;
}
table.mytable tbody tr:nth-child(even) {
background: #f6f6f6;
}
@media screen and (max-width: 767px) {
table.mytable caption {
background-image: none;
}
table.mytable thead {
display: none;
}
table.mytable tbody td {
display: block;
padding: 10px;
text-align: left;
}
table.mytable tbody td:before:before {
content: attr(data-th);
font-weight: bold;
display: inline-block;
width: 100%;
}
}
@media screen and (max-width: 767px) {
table.mytable thead th {
padding: 10px;
}
table.mytable tbody td {
padding: 10px;
}
}