Search code examples
htmlcssglyphiconsfontello

can't link to an external stylesheet for fontello


I want to see this:

two arrows

It works when I include the modified fontello CSS in between <style></style> tags:

<!DOCTYPE html>
<html>

    <head>
        <meta charset="UTF-8">
        <!-- <link rel="stylesheet" type="text/css" href="css/fontello_mod.css"/> -->
    </head>

<style>

@font-face {
    font-family: 'fontello';
    src: url('font/fontello.eot?47332372');
    src: url('font/fontello.eot?47332372#iefix') format('embedded-opentype'),
             url('font/fontello.woff?47332372') format('woff'),
             url('font/fontello.ttf?47332372') format('truetype'),
             url('font/fontello.svg?47332372#fontello') format('svg');
    font-weight: normal;
    font-style: normal;
}

.icon {
    font-family: "fontello";
    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: 220%;

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

}

</style>

    <body>
        <i class="icon">&#xe800;</i><i class="icon">&#xe801;</i>
    </body>
</html>

So because everything seemed fine, I moved the CSS into an external sheet and removed the <style></style> bits:

<!DOCTYPE html>
<html>

    <head>
        <meta charset="UTF-8">
        <link rel="stylesheet" type="text/css" href="css/fontello_mod.css"/>
    </head>

<!-- <style></style> -->

    <body>
        <i class="icon">&#xe800;</i><i class="icon">&#xe801;</i>
    </body>
</html>

But now, my icons look like this:

all messed up

The CSS between the two are identical (copy & paste). Why is this happening? How do I fix it?

I'm not sure if it's relevant, but I'm using Chrome and XAMPP (Apache only) right now.

EDIT:

Here is my folder structure:

folder structure

The html document is called demo.html and is in the folder A2 (http://localhost/573/A2/demo.html). The CSS stylesheet is A2/css/fontello_mod.css.


Solution

  • Your css file isn't getting the font folder. Place your "fontello" font folder inside that css folder.