如何使用 thymeleaf 解析的 url 设置样式标签的背景属性。
我有
<div style="background:url('<url-to-image>')"></div>
有没有<img th:src="${@/<path-to-image>}">
相当于在 thymeleaf 中设置样式属性。
最佳答案
如果您使用 th:style
设置您的样式属性,您可以实现这一点:
<div th:style="'background:url(' + @{/<path-to-image>} + ');'"></div>
检查 this thymeleaf 论坛上的帖子。
关于css - 使用 thymeleaf 设置 CSS 样式属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29140647/