arielsalminen / ResponsiveSlides.js

Simple & lightweight responsive slider plugin (in 1kb)
http://responsiveslides.com
3.46k stars 1.52k forks source link

Using Font Awesome icons as prevText and nextText #380

Closed bjtalbot1 closed 7 years ago

bjtalbot1 commented 7 years ago

When I use Font Awesome icons for the prevText and nextText options, like this:

prevText: '<i class="fa fa-chevron-circle-left">',
nextText: '<i class="fa fa-chevron-circle-right">',

... the HTML doesn't come out right—the prevText icon gets duplicated somehow, coming out like this:

<a href="#" class="rslides_nav rslides1_nav prev">
    <i class="fa fa-chevron-circle-left"></i>
</a>

<i class="fa fa-chevron-circle-left">
    <a href="#" class="rslides_nav rslides1_nav next">
        <i class="fa fa-chevron-circle-right"></i>
    </a>
</i>

Any suggestions on how to fix this? I'm kind of a JavaScript beginner. Thanks for any help!

danielbenjamins commented 7 years ago

You have to use the unicode instead of HTML. For fa-chevron-circle-left it's "f137". You have to add "&#x" before the unicode and ";" after to make it work:

prevText: "&#xf137;",   // String: Text for the "previous" button
bjtalbot1 commented 7 years ago

Thank you, but when I use that exact code, I just get a box (unfilled) as output.

danielbenjamins commented 7 years ago

Sorry, I forgot to mention that you also have to assign the FontAwesome font to the div or span.

Example:

.prev {
font-family: "FontAwesome";
}
bjtalbot1 commented 7 years ago

Ah, yes, that was it! Thank you so much!!