简体   繁体   中英

Materializecss icons are disappearing from html after using th:text attribute from thymeleaf

I am currently learning web app development with Spring and during that I encountered with annoying problem.

So lets get to the point. I am using materializecss which allows to make a button with icon just by:

<button class="waves-effect waves-light btn" type="submit" name="save">Send
    <i class="material-icons left">send</i>
</button>

And i am getting a nice button with icon: link

But as soon as I add a thymeleaf attribute th:text it causes disappearing of the icon.

Thats the code:

<button class="waves-effect waves-light btn" type="submit" name="save"
        th:text="#{submit}">Send
    <i class="material-icons right">send</i>
</button>

Do you have any idea what can be the reason?

th:text overwrites all children tag. You have to move the text to it's own tag. Like this, for example:

<button class="waves-effect waves-light btn" type="submit" name="save">
    <span th:text="#{submit}" />
    <i class="material-icons right">send</i>
</button>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM