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

后端 未结 10 971
無奈伤痛
無奈伤痛 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:13

    Yes, it is possible to change a CSS class dynamically according to the situation, but not with th:if. This is done with the elvis operator.

    Lorem Ipsum 
    

提交回复
热议问题