Thymeleaf - How To Apply Two (or More) Styles Based On Mutually Exclusive Conditions
I need to have rows in a table alternate background color. I also need to have the text color in the rows be dependent on a value. How can I do this using Thymeleaf? Here's the cod
Solution 1:
Thymeleaf has a th:styleappend attribute that allows for multiple styles to be applied:
<tr th:each="item, rowStat : ${items}"
th:style="${rowStat.odd} ? 'background: #f0f0f2;' : 'background: #ffffff;'"
th:styleappend="${item.getValue()} > 5 ? 'color: red;' : 'color: black;'">
<td.... <!-- cols>
</tr>
Post a Comment for "Thymeleaf - How To Apply Two (or More) Styles Based On Mutually Exclusive Conditions"