所以我试图原型营销页面,我使用Bootstrap和新的字体Awesome文件。问题是,当我尝试使用图标时,所有在页面上呈现的都是一个大正方形。

以下是我如何将文件包含在头部:

<head>
        <title>Page Title</title>
        <link rel="stylesheet" href="css/bootstrap.css">
        <link rel="stylesheet" href="css/bootstrap-responsive.css">
        <link rel="stylesheet" href="css/font-awesome.css">
        <link rel="stylesheet" href="css/app.css">
        <!--[if IE 7]>
            <link rel="stylesheet" href="css/font-awesome-ie7.min.css">
        <![endif]-->
</head>

这是我尝试使用图标的一个例子:

<i class="icon-camera-retro"></i>

但所有这些都被渲染在一个大正方形中。有人知道这是怎么回事吗?


当前回答

我使用字体Awesome 4.3.0只是链接从maxcdn工作在这里提到,

但是在你的服务器上,把字体和CSS放在同一个文件夹里对我来说是有效的,就像这样

然后只需链接CSS:

<link href="~/fonts/font-awesome.min.css" rel="stylesheet" />

其他回答

使用这个<i class="fa fa-camera-retro" ></i>你还没有定义fa类

截至2018年12月,我发现使用bootstrapcdn上的稳定版本4.7.0比使用字体很棒的5.x更容易。x cdn在他们的网站上——因为每次他们升级小版本,以前的版本都会崩溃。

<link media="all" rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">

图标是一样的:

<i class="fa fa-facebook"></i>

这对我不起作用,因为我在apache配置中对根目录设置了Allow from none指令。下面是我如何让它工作的……

我的目录结构:

root/
root/font-awesome/4.4.0/css/font-awesome.min.css
root/font-awesome/4.4.0/fonts/fontawesome-webfont.*
root/dir1/index.html

我的index.html有:

<link rel="stylesheet" href="../font-awesome/4.4.0/css/font-awesome.min.css">

我选择继续禁止访问我的根目录,而是在我的apache配置中为root/font-awesome/添加了另一个目录条目

<Directory "/path/root/font-awesome/">
    Allow from all
</Directory>

在苦苦寻找解决方案,但发现官方文档没有帮助之后,这为我解决了问题:

下载fontawessome .zip。我使用版本5.10.2,我得到了它从这里https://fontawesome.com/download 在zip文件中有几个文件夹。你只需要css和webfonts文件夹 在你的web项目中创建2个文件夹,命名为css和webfonts。

这些名字是必须的。现在从压缩文件中复制css和webfonts的内容到项目中的相应文件夹中。这就是全部!

当心fontawesome !卓越就是让事情变得简单!

我使用字体Awesome 4.3.0只是链接从maxcdn工作在这里提到,

但是在你的服务器上,把字体和CSS放在同一个文件夹里对我来说是有效的,就像这样

然后只需链接CSS:

<link href="~/fonts/font-awesome.min.css" rel="stylesheet" />