JSFiddle - React, Tailwind, and code Playground

by Henry

HTML

<table id="expenses">
<thead>
<tr>
<th>Expense</th>
<th>2014</th>
<th>2015</th>
<th>2016</th>
</tr>
</thead>
<tbody>
<tr>
<td>Salaries</td>
<td>$85,256</td>
<td>$65,487</td>
<td>$94,626</td>
</tr>
<tr>
<td>Publication costs</td>
<td>22,698</td>
<td>69,548</td>
<td>66,555</td>
</tr>
<tr>
<td><strong>Total Expenses</strong></td>
<td><strong>$126,061</strong></td>
<td><strong>$169,013</strong></td>
<td><strong>$65,887</strong></td>
</tr>
</tbody>
</table>

CSS

table {
    border-collapse: collapse;
    width: 100%;
    color: #444;
}
tr:nth-of-type(2n+1) {
    background: #eee none repeat scroll 0 0;
}
th {
    background: #696969 none repeat scroll 0 0;
    color: #fff;
    font-weight: bold;
}
td, th {
    border: 1px solid #ccc;
    padding: 6px;
    text-align: left;
    vertical-align: middle;
}
/* responsive code */
@media
only screen and (max-width: 760px),
(min-device-width: 768px) and (max-device-width: 1024px)  {
    /* Force table to not be like tables anymore */
    table, thead, tbody, th, td, tr {
        display: block;
    }
    /* Hide table headers (but not display: none;, for accessibility) */
    thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }
    tr { border: 1px solid #ccc; }
    td {
        /* Behave  like a "row" */
        border: none;
        border-bottom: 1px solid #eee;
        position: relative;
        padding-left: 50%;
    }
    td:before {
        /* Now like a table header */
        position: absolute;
        /* Top/left values mimic padding */
        top: 6px;
        left: 6px;
        width: 45%;
        padding-right: 10px;
        white-space: nowrap;
    }
    /* Grants and Contracts table */
    table td:nth-of-type(1)::before { content: "Expense"; }
    table td:nth-of-type(2)::before { content: "2014"; }
    table td:nth-of-type(3)::before { content: "2015"; }
    table td:nth-of-type(4)::before { content: "2016"; }
    table td:last-of-type {display: none;}
}