JSFiddle - React, Tailwind, and code Playground
HTML
<table>
<thead>
<tr>
<th>Name</th>
<th>0.1</th>
<th>0.2</th>
<th>0.3</th>
</tr>
</thead>
<tbody>
<tr>
<td>Allan, Paul</td>
<td>-9</td>
<td>-9</td>
<td>-9</td>
</tr>
<tr>
<td>Bartlett, James</td>
<td>-5</td>
<td>-5</td>
<td>-5</td>
</tr>
<tr>
<td>Callow, Simon</td>
<td>-2</td>
<td>-2</td>
<td>-2</td>
</tr>
<tr>
<td>Dennis, Mark</td>
<td>-1</td>
<td>-1</td>
<td>-1</td>
</tr>
<tr>
<td>Ennals, Simon</td>
<td>1</td>
<td>1</td>
<td>1</td>
</tr>
<tr>
<td>Finnegan, Seamus</td>
<td>2</td>
<td>2</td>
<td>2</td>
</tr>
<tr>
<td>Goldberg, John</td>
<td>9</td>
<td>9</td>
<td>9</td>
</tr>
</tbody>
</table>
CSS
table {
width: 13em;
}
th {
border-bottom: 2px solid #ccc;
padding: 0.1em 0 0.0em 0;
font-size: .9em;
}
td {
border-bottom: 0px solid #ccc;
padding: 0.1em 0 0.1em 0;
text-align: center;
}
.abovePlus {
background-color: #1b7837; color: #fff;
}
.above {
background-color: #7fbf7b; color: #000;
}
.high {
background-color: #d9f0d3; color: #000;
}
.at {
background-color: #ffffff; color: #000;
}
.low {
background-color: #e7d4e8; color: #000;
}
.below {
background-color: #af8dc3; color: #000;
}
.belowPlus {
background-color: #762a83; color: #fff;
}
JavaScript
$(function() {
$( "td" ).each(function(index) {
var scale = [['abovePlus', 20, 20], ['above', 5, 6], ['high', 2, 1], ['at', 0, 0], ['low', -1, -2], ['below', -2, -4], ['belowPlus', -9, -9]];
var score = $(this).text();
var column = [[0, 1], [1, 1], [2, 2], [3, 1]];
for (var i = 0; i < scale.length; i++)
{
if (score <= scale[i][1]) {
$(this).addClass(scale[i][0]);
}
}
});
});