Search code examples
thymeleaf

Thymeleaf add value in style


I have a div block that has styles. I need to add another style with a substitution value. I imagined it like this:

th:styleappend="background-position:-${value}%"

But it doesn't work. Is there a possibility to do this?


Solution

  • Most probably you are having a syntax issue here. Try the following code:

    th:styleappend="'background-position:-' + @{${value}} + '%'"