3

PROBLEM

The <a> tag on which I have applied a font-icon from fontello.com renders like this on the web page, though it is supposed to be this left or right arrow:

enter image description here

BACKGROUND

I used the first four points from this answer as a tutorial to use a font from fontello.com. I don't fully understand the 5th point (the <i> tag part) but it is optional as well.

........

I need a standalone (i.e. Not with text) glyph icon on an <a> element, so I did this:

<a href="" class="left-arrow icon-angle-left"></a>

and

<a href="" class="right-arrow icon-angle-right"></a>

and in the CSS for this <a> element:

.right-arrow, .left-arrow {
    font-family: 'arrows';
    ...
}

.........

Here is the arrows.css file from the CSS folder downloaded from fontello.com:

@font-face {
  font-family: 'arrows';
  src: url('../font/arrows.eot?42097229');
  src: url('../font/arrows.eot?42097229#iefix') format('embedded-opentype'),
       url('../font/arrows.woff?42097229') format('woff'),
       url('../font/arrows.ttf?42097229') format('truetype'),
       url('../font/arrows.svg?42097229#arrows') format('svg');
  font-weight: normal;
  font-style: normal;
}
/* Chrome hack: SVG is rendered more smooth in Windozze. 100% magic, uncomment if you need it. */
/* Note, that will break hinting! In other OS-es font will be not as sharp as it could be */
/*
@media screen and (-webkit-min-device-pixel-ratio:0) {
  @font-face {
    font-family: 'arrows';
    src: url('../font/arrows.svg?42097229#arrows') format('svg');
  }
}
*/

 [class^="icon-"]:before, [class*=" icon-"]:before {
  font-family: "arrows";
  font-style: normal;
  font-weight: normal;
  speak: none;

  display: inline-block;
  text-decoration: inherit;
  width: 1em;
  margin-right: .2em;
  text-align: center;
  /* opacity: .8; */

  /* For safety - reset parent styles, that can break glyph codes*/
  font-variant: normal;
  text-transform: none;

  /* fix buttons height, for twitter bootstrap */
  line-height: 1em;

  /* Animation center compensation - margins should be symmetric */
  /* remove if not needed */
  margin-left: .2em;

  /* you can be more comfortable with increased icons size */
  /* font-size: 120%; */

  /* Font smoothing. That was taken from TWBS */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;

  /* Uncomment for 3D effect */
  /* text-shadow: 1px 1px 1px rgba(127, 127, 127, 0.3); */
}

.icon-angle-right:before { content: '\e800'; } /* '' */
.icon-angle-left:before { content: '\e801'; } /* '' */

EDIT @Pauli_D

Yes I have them there. I have created a little demo project (I don't know how to add fontello in JSFiddle, so posting the code here) :

index.php:

<?php  

echo '<!DOCTYPE html>
<html>
    <head>      
        <meta charset="utf-8"/>
        <title>Test for Glyph Icon from Fontello</title>
        <link rel="stylesheet" type="text/css" href="style.css"/>
        <link rel="stylesheet" type="text/css" href="arrows.css"/>
    </head>
    <body>';

        echo '<a href="" class="right-arrow icon-angle-right"></a>';

        echo '<br><br><br>';

        echo '<a href="" class="left-arrow icon-angle-left"></a>';

    echo '</body>
    </html>';

?>

style.css:

.right-arrow, .left-arrow {
    font-family: 'arrows';
    color: #313131;
    text-align: center;
    text-decoration: none;
    width: 40px;
    font-size: 40px;
    padding-bottom: 60px;
    padding-top: 20px;
    filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=60);
    opacity: 0.6;
    -webkit-transition: opacity 0.3s ease;
    -moz-transition: opacity 0.3s ease;
    -o-transition: opacity 0.3s ease;
    transition: opacity 0.3s ease;
}

arrows.css is same as above

..............

enter image description here

Community
  • 1
  • 1
Solace
  • 8,612
  • 22
  • 95
  • 183
  • 1
    You do have the font actually installed in the folder...don't you? Can you demo this? Is it in any specific browser or all of them? – Paulie_D May 27 '15 at 12:12
  • @Paulie_D I edited the question. By "installed in the folder", I am assuming that you mean the font files (`.eot`, `.svg`, `.ttf`, `.woff` files from the `fonts` folder in the package downloaded from fontello) are _located_ there. Yes, they are located there. – Solace May 27 '15 at 13:05
  • Then I suggest that you'll have to demo this not working on a **live** page. – Paulie_D May 27 '15 at 13:50
  • @Paulie_D Thanks for your suggestions, can you just tell me if by a **live** webpage, you mean the code snippets inserted here in SO? I don't know how to add Fontello fonts to them. – Solace May 27 '15 at 13:55
  • No, you'd have to create an actual website and have it hosted somewhere so we can see this not working. at the moment we can't reproduce the issue so we're taking wild guesses. This is likely to get the question closed. – Paulie_D May 27 '15 at 14:02
  • First, verify in browser dev tools that the font file is actually being loaded. Second, is there additional CSS for your classes that specifies a `content` property? What are `.icon-angle-left` and `.icon-angle-right` CSS? – CodingWithSpike May 27 '15 at 14:35

2 Answers2

1

Try

<a href=""><i class="left-arrow icon-angle-left"></i></a>
<a href=""><i class="right-arrow icon-angle-right"></i></a>

The 5th step refers only to applying zero margin to your icons.


EDIT:

Keep your <a> elements as you have them now, no need to edit.

Edit paths in arrows.css file and remove ../ from the beginning of paths.

@font-face {
font-family: 'arrows';
src: url('font/arrows.eot?42097229');
src: url('font/arrows.eot?42097229#iefix') format('embedded-opentype'),
     url('font/arrows.woff?42097229') format('woff'),
     url('font/arrows.ttf?42097229') format('truetype'),
     url('font/arrows.svg?42097229#arrows') format('svg');
font-weight: normal;
font-style: normal;
}
mirek
  • 93
  • 9
  • Did not help. You can see the edit in the question as well, to see a complete demo project. – Solace May 27 '15 at 13:07
  • Try to remove `font-family: 'arrows';` from your css in `.right-arrow, .left-arrow {}`. The font-family is assigned to the element by its icon-* class – mirek May 27 '15 at 13:33
  • Works for me when I tried with Font Awesome - see [jsfiddle](http://jsfiddle.net/xq9s4Lpb/). – mirek May 27 '15 at 13:38
  • Your suggestions to try things! No offense but are you making random guesses? If not, please also state a reason when you suggest somebody to _try_ something. – Solace May 27 '15 at 13:41
  • The question about Fontello. – Solace May 27 '15 at 13:42
  • Sorry if it doesn't work, it wasn't random guess. As I don't have your custom Fontello font, I have used another icon font - they work on same principle. When you place `

    ` at the beginning of your page, does the icon appear? If not, the path to the font files is probably wrong. Remove `../` from the beginning of paths in your arrows.css file.
    – mirek May 27 '15 at 13:56
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/78917/discussion-between-zarah-and-mirek). – Solace May 27 '15 at 13:58
0

cause you are using the free "demo" fonts, and thus have to add the "demo-icon" class to every class you add each icon. Example:

<i class="demo-icon left-arrow icon-angle-left"></i>

barry
  • 1
  • 1
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 16 '22 at 13:35