3
The doubt may be silly but I really don’t know how to do it. It is possible to escape an awesomefonts icon (already installed in the project) inside an HTML attribute, in this case the data-text?
Follow CSS/HTML, thank you all!
.primary-bg{
    width: 237px;
    margin: 5px 5px;
    /* Secondary color */
    background-color: rgb(27, 99, 245);
    -moz-border-radius:7px;
    -webkit-border-radius:7px;
    border-radius:7px;
    display: inline-block;
}
.btn
{
    line-height: 55px;
    width: 100%;
    height: 60px;
    text-align: center;
    margin-right: auto;
    margin-left: auto;
    cursor: pointer;
    -moz-border-radius:7px;
    -webkit-border-radius:7px;
    border-radius:7px
}
.btn1 {
    color: rgba(255,255,255);
    -webkit-transition: all 0.5s;
    -moz-transition: all 0.5s;
    -o-transition: all 0.5s;
    transition: all 0.5s;
    position: relative;
    overflow: hidden;
    /* Primary color */
    background-color: rgb(29, 85, 148);
}
.btn1 a{
    color: rgba(51,51,51,1);
    text-decoration: none;
    display: block;
}
.btn1 span {
    -webkit-transition: all 0.5s;
    -moz-transition: all 0.5s;
    -o-transition: all 0.5s;
    transition: all 0.5s;
}
.btn1:hover{
    background-color: rgba(255,255,255,0.2);
    width: 100%;
}
.btn1:hover > span{
    opacity: 0;
    -webkit-transform: translate(0px,40px);
    transform: translate(0px,40px);
}
.btn1::after{
    content: attr(data-text);
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    opacity: 0;
    -webkit-transform: translate(-30%, 0);
    transform: translate(-30%, 0);
    -webkit-transition: all 0.3s;
    -moz-transition: all 0.3s;
    -o-transition: all 0.3s;
    transition: all 0.3s;   
}
.btn1:hover::after{
    opacity: 1;
    -webkit-transform: translate(0, 0);
    transform: translate(0, 0);
}<div class="primary-bg">
  <div class="btn btn1" data-text="Icone+TextoAqui"><span>Ícone após o hover</span></div>
</div>
Thanks for the answer, it worked for me, but only when I use the Cdn you put at the beginning of css. When I put the tags <i class="fas fa-search"></i> get the icon normally. Could you tell me what happens?
– João
When I put the tags <i class="fas fa-search"></i> anywhere on my page I get the icon, which means I’m correctly importing the file from awesome sources with the tags <link rel="stylesheet" href="css/fontawesome-all.min.css">
– João
It works! What doesn’t work is Unicode() when I withdraw Cdn.
– João
I am using the 5.0 but I believe that is not the problem because I downloaded and imported the one you used and the problem continues. Is it because I’m using it on localhost? I use laragon as a server for projects.
– João
The problem is in version 5, does not accept Unicode. I downloaded the 4.7 of the site with the css/fonts folders and it worked perfectly. I didn’t understand the reason why it doesn’t work Unicode with 5, I’ll take a look at the release later. I appreciate the strength. God Bless!
– João
Not wanting to ask a lot but already asking, would you know how to give a font-size in that Nicode? With pseudo element I can but this is inside an attr in the case.
– João
Yes, I’ve done it, but what I want to do is just increase the icon.
– João
Solved for me, thank you very much. God Bless!
– João