Both existing answers are good, and this is not an attempt to displace them. This improves them, which can be used if you want a flexible design with gradients.
As mentioned in the other two answers (and in the snippet below), the gradient angles should be changed if the height or width td changes. This is a drawback when then the design should be responsive, but it can be avoided by using the gradient syntax to [side] [side] instead of corner gradients. This syntax can adapt to any resizing.
td { background: linear-gradient(to top right, #167891 49.5%, #0D507A 50.5%); color: #fff; }
Inside the text, additional positioning is required to make it look exactly the same as in the question.
tr:nth-child(3) td { background: linear-gradient(to top right, #167891 49.5%, #0D507A 50.5%); color: #fff; } tr:nth-child(1) td { background: linear-gradient(18deg, #167891 50%, #0D507A 51%); color: #fff; } tr:nth-child(2) td { background: linear-gradient(33deg, #167891 50%, #0D507A 51%); color: #fff; } table { float: left; } table:nth-child(2) td { height: 50px; } table:nth-child(3) td { height: 100px; } table:nth-child(4) td { height: 150px; }
<script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script> <table> <tr><td>Two Color Background</td></tr> <tr><td>Two Color Background</td></tr> <tr><td>Two Color Background</td></tr> </table> <table> <tr><td>Two Color Background</td></tr> <tr><td>Two Color Background</td></tr> <tr><td>Two Color Background</td></tr> </table> <table> <tr><td>Two Color Background</td></tr> <tr><td>Two Color Background</td></tr> <tr><td>Two Color Background</td></tr> </table>
Harry
source share