首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法链接到fontello的外部样式表

无法链接到fontello的外部样式表
EN

Stack Overflow用户
提问于 2016-04-04 05:24:47
回答 3查看 1.2K关注 0票数 1

我想看看这个:

当我在<style></style>标记之间包含修改后的fontello时,它可以工作:

代码语言:javascript
复制
<!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>

因此,由于一切看起来都很好,所以我将CSS移到外部工作表中,并删除了<style></style>位:

代码语言:javascript
复制
<!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>

但是现在,我的图标看起来是这样的:

两者之间的CSS是相同的(复制和粘贴)。为什么会发生这种情况?我该怎么修呢?

我不确定这是否相关,但我现在正在使用Chrome和XAMPP (仅限于Apache)。

编辑:

这是我的文件夹结构:

html文档名为demo.html,位于文件夹A2 (http://localhost/573/A2/demo.html)中。CSS样式表是A2/css/fontello_mod.css

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2016-04-04 05:32:57

您的css文件没有获得font文件夹。将您的"fontello“字体文件夹放在该css文件夹中。

票数 1
EN

Stack Overflow用户

发布于 2016-04-04 05:31:02

如果将代码移动到外部源,则检查字体文件的路径。

然后你必须写上"../“之类的词:

代码语言:javascript
复制
url('../font/fontello.eot?47332372');
票数 2
EN

Stack Overflow用户

发布于 2016-04-04 06:05:34

将所有字体urls更改为

代码语言:javascript
复制
@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;

}

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36395099

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档