Thymeleaf: how to use conditionals to dynamically add/remove a CSS class

后端 未结 10 1097
無奈伤痛
無奈伤痛 2020-12-12 15:04

By using Thymeleaf as template engine, is it possible to add/remove dynamically a CSS class to/from a simple div with the th:if clause?

Nor

10条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-12 15:28

    There is also th:classappend.

    
    

    If isAdmin is true, then this will result in:

    
    

提交回复
热议问题