【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