Waylan Punch
Waylan Punch

Reputation: 269

How to refer a background-image in a div's style attribution?

Rest Api http://localhost:8091/zine/admin/index leads to this page src\main\resources\templates\admin\index.html.

Here is the code in Thymeleaf , admin/index.html:

<div class="card__header card__header--img" style="background-image: url("@{/admin/demo/img/note.png}"); height: 250px;"></div>

Resources folders: note.png

It's absolute path which you can see : src\main\resources\static\admin\demo\img\note.png

But seems won't work with this code :

style="background-image: url("@{/admin/demo/img/note.png}"); height: 250px;"

Can anyone help me with this?

Upvotes: 0

Views: 420

Answers (1)

Waylan Punch
Waylan Punch

Reputation: 269

Good Now.

<div class="card__header card__header--img" th:style="'background-image:url('+@{/admin/demo/img/note.png}+'); height: 250px;'"></div>

A warning came out:enter image description here

Just ignore it.

Probably someone has even better solution, please share.

Upvotes: 0

Related Questions