2

I have an <li> that when hovered is supposed to change a number into a unicode icon, for example a play button.

The unicodes keep popping up an icon that looks like this: [?] I'm assuming it can't find them. I am using font icons in other parts just fine, any ideas?

    <ul class="popular-songs">
            <li>
<div class="album-cover"><img src="http://newnoisemagazine.com/wp-content/uploads/2014/04/Expire-Pretty-Low-cover.jpg"></div> 
<span class="number">
<span>1</span>
</span> 
<span>+</span>
<span class="title">Pretty Low</span>
<span class="misc"><i class="fa fa-ellipsis-h"></i></span>
<span class="total-plays">163,957</span></li>
        </ul>

CSS:

.popular-songs li .number{
  position: relative;
  content: '1';
  top:0px;
}
.popular-songs li:hover .number span{
  display: none;
}
.popular-songs li:hover .number:after{
  content: "\f04b";
  position:relative;
  top:15px;
}

I have tried writing the unicode in every possible way I could think of.

content: "/XXXX";

content: "\XXXX";

content: "XXXX";

content: "[XXXX]";

None of them seem to work for me.

3
  • I don't see a definition for font-family in your css, are you setting the font to font-family: 'FontAwesome';?
    – Ted
    Commented Apr 15, 2015 at 14:50
  • I have the cdn in my head tag Commented Apr 15, 2015 at 14:51
  • That's a start, but that's not enough... see my answer below
    – Ted
    Commented Apr 15, 2015 at 14:53

1 Answer 1

6

Add the font-family to your CSS, like:

.popular-songs li:hover .number:after{
  font-family: 'FontAwesome';
  content: "\f04b";
  position:relative;
  top:15px;
}

And just for reference, here's FontAwesomes CSS for all icons:

.fa {
  display: inline-block;
  font: normal normal normal 14px/1 FontAwesome;
  font-size: inherit;
  text-rendering: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transform: translate(0, 0);
}
2
  • Ah, I see! Perfect, thanks for the help! (Will accept answer as soon as it lets me). Commented Apr 15, 2015 at 14:55
  • Having the CDN link alone does not apply FontAwesome to everything; you must specify font-family, which is why this is the correct answer.
    – Feign
    Commented Apr 15, 2015 at 14:56

Not the answer you're looking for? Browse other questions tagged or ask your own question.