简体   繁体   English

字体真棒显示框而不是图标

[英]Font Awesome Showing Box instead of Icons

I've imported all the font awesome css into my website using the following link code: 我使用以下链接代码将所有字体真棒css导入我的网站:

<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" />
 <link href="content/css/font-awesome/css/font-awesome.css" rel="stylesheet" />
<link href="content/css/theme.min.css" rel="stylesheet" />
<link href="content/css/WDWStyles.css" rel="stylesheet" />

And then added the icons using: 然后使用以下方法添加图标:

<p>Find me at:</p>
<a class="btn btn-primary"><span class="fa fa-twitter"></span> Twitter</a> 
<a class="btn btn-primary"><span class="fa fa-github"></span> Github</a>     
<a class="btn btn-primary"><span class="fa fa-linkedin"></span> Linked in</a>

My custom CSS is: 我的自定义CSS是:

@font-face {
    font-family: 'headline_onehplhs';
    src: url('fonts/HEADOH__-webfont.eot');
    src: url('fonts/HEADOH__-webfont.eot?#iefix') format('embedded-opentype'),
         url('fonts/HEADOH__-webfont.woff2') format('woff2'),
         url('fonts/HEADOH__-webfont.woff') format('woff'),
         url('fonts/HEADOH__-webfont.ttf') format('truetype'),
         url('fonts/HEADOH__-webfont.svg#headline_onehplhs') format('svg');
    font-weight: normal;
    font-style: normal;

}

body {
  background-image: url('../images/background.jpg');
  background-position: top center;
  background-repeat: no-repeat;
  background-attachment: fixed;
  background-size: cover;
}

.heading {
    background-color:#FFF;
    font-family: 'headline_onehplhs';
    font-size:3.5em;
    margin-left:50px;
    margin-top:50px;
    padding:20px;
    color:#000;
}

.heading span, .main span {
    background-color:#FFF;
    font-family: 'headline_onehplhs';
    color:#999;
    font-size:0.5em;
    display:block;
}

.main span {
    font-size:1.75em;
}

.main {
    background-color:#FFF;
    margin-left:50px;
    margin-top:25px;
    padding:20px;
    text-align:justify;
}

My directory is laid out as follows: 我的目录布局如下:

css > font-awesome > [font awesome folders] css> font-awesome> [font awesome folders]

And the container that I'm using has the class name "main" 我正在使用的容器的类名为“main”

But the icons still display as square boxes - is there something I'm missing? 但图标仍然显示为方框 - 有什么我想念的吗?

Try to use <i class="fa fa-twitter"> rather than <span class="fa fa-twitter"> 尝试使用<i class="fa fa-twitter">而不是<span class="fa fa-twitter">

On the official doc: 在官方文件:

After you get up and running, you can place Font Awesome icons just about anywhere with the <i> tag. 启动并运行后,您可以使用<i>标签放置Font Awesome图标。

It also says: 它还说:

You can place Font Awesome icons just about anywhere using the CSS Prefix fa and the icon's name. 您可以使用CSS前缀fa和图标名称在任何地方放置Font Awesome图标。 Font Awesome is designed to be used with inline elements (we like the <i> tag for brevity, but using a <span> is more semantically correct). Font Awesome旨在与内联元素一起使用(为简洁起见,我们喜欢<i>标签,但使用<span>在语义上更正确)。

Although it sounds like using <span> is also acceptable, but it does not work correctly in some cases, so stay with <i> is a safer plan. 虽然听起来像使用<span>也是可以接受的,但在某些情况下它无法正常工作,所以坚持<i>是一个更安全的计划。

Use this instead: 请改用:

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

If that fixes your problem, then you either didn't upload the fonts in the correct directory or you are referencing them incorrectly. 如果这样可以解决您的问题,那么您要么没有将字体上传到正确的目录中,要么就是错误地引用了它们。

Here is a test showing the minimum code required to use font awesome: 这是一个测试,显示使用字体awesome所需的最小代码:

 <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" rel="stylesheet"/> <i class="fa fa-camera-retro fa-lg"></i> fa-lg <i class="fa fa-camera-retro fa-2x"></i> fa-2x <i class="fa fa-camera-retro fa-3x"></i> fa-3x <i class="fa fa-camera-retro fa-4x"></i> fa-4x <i class="fa fa-camera-retro fa-5x"></i> fa-5x 

Noone has mentioned the font folder in relation to the fonts. 没人提到与字体有关的字体文件夹。 Think like why in you have to put ../ in front of background image to let it know that the img Is not contained in the CSS folder. 想想为什么你必须在背景图像前放置../让它知道img不包含在CSS文件夹中。 Check the font-awesome.css file and see where it Is referencing the fonts. 检查font-awesome.css文件,看看它引用字体的位置。

Maybe like this? 也许是这样的?

HTML link HTML链接

<link href='content/css/font-awesome/css/font-awesome.css?family=font+awesome' rel='stylesheet' type='text/css'>

CSS CSS

fa{
   font-family: 'font awesome';
  }

Source: similar use http://www.google.com/fonts#QuickUsePlace:quickUse 来源:类似使用http://www.google.com/fonts#QuickUsePlace:quickUse

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM