【Thymeleaf】利用th:style设置表格行奇偶色


设置序号:

    th:text="${status.index+1}"

设置td的间隔色:
    th:style="'background-color:'+(${status.odd}?'#fff':'#f5f2eb')"

代码:

<tbody>
    <tr th:each="reputaton,status:${rptns}">
        <tr th:each="reputaton,status:${rptns}">
        <td th:text="${status.index+1}"    th:style="'background-color:'+(${status.odd}?'#fff':'#f5f2eb')"></td>
        <td th:text="${reputaton.id}"      th:style="'background-color:'+(${status.odd}?'#fff':'#f5f2eb')"></td>
        <td th:text="${reputaton.deleted}" th:style="'background-color:'+(${status.odd}?'#fff':'#f5f2eb')"></td>
        <td th:text="${reputaton.name}"    th:style="'background-color:'+(${status.odd}?'#fff':'#f5f2eb')"></td>
        <td th:text="${reputaton.brief}"   th:style="'background-color:'+(${status.odd}?'#fff':'#f5f2eb')"></td>
        <td th:text="${reputaton.creater}" th:style="'background-color:'+(${status.odd}?'#fff':'#f5f2eb')"></td>
        <td th:text="${reputaton.ctime}"   th:style="'background-color:'+(${status.odd}?'#fff':'#f5f2eb')"></td>
    </tr>
    </tr>
</tbody>

效果:

 END


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM