Html 如何在 CSS 中添加很棒的字体
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37460680/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to add font awesome in CSS
提问by user agent
I am trying to add a an icon from font awesome but for some reason it does not appear when I load the page. Below is my html code in which I attempted to add the font awesome in different ways.
我正在尝试从 font awesome 中添加一个图标,但由于某种原因,当我加载页面时它没有出现。下面是我尝试以不同方式添加字体的 html 代码。
<html lang="en">
<head>
<title>Media Queries</title>
<meta name="viewport" content="width=device-width, initial=scale1.0">
<link rel="stylesheet" href="main.css">
<link href='https://fonts.googleapis.com/css?family=Lato:100' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Lato' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Open+Sans:700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="font-awesome-4.6.3/css/font-awesome.min.css">
</head>
<body>
<i class="fa fa-car" aria-hidden="true"></i>
<h1>
<i class="fa fa-car" aria-hidden="true"></i>Dummy Text
</h1>
</body>
</html>
Is there anything that am missing in the code?
代码中是否缺少任何内容?
采纳答案by Elton Sousa
What you put in your link is the name of your folder.You should put the name of the file instead(font-awesome)
您在链接中输入的是文件夹的名称。您应该输入文件的名称(字体真棒)
On the font-awesome folder look for the file called font-awesome,copy and paste on your browser text field so that you can see the correct path. Copy that path and paste in your link like this:
在 font-awesome 文件夹中查找名为 font-awesome 的文件,复制并粘贴到您的浏览器文本字段,以便您可以看到正确的路径。复制该路径并粘贴到您的链接中,如下所示:
<link rel="stylesheet" href="font-awesome/css/font-awesome.css">
Just check the path correctly cause I see no other mistake. let me know if it does not work.
只需正确检查路径,因为我看不到其他错误。如果它不起作用,请告诉我。
回答by Sayed Rafeeq
You can add font-awesome css file in your "main.css" file
您可以在“ main.css”文件中添加字体很棒的 css文件
@import url('/font-awesome-4.6.3/css/font-awesome.min.css');
回答by Mukesh Ram
Try to call form font-awesome like this:
尝试像这样调用 form font-awesome :
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css">
Or if you try from your site folder then download font-awesome and add fonts into your fonts folder and add font-awesome css into css folder then call it like this:
或者,如果您尝试从您的站点文件夹中下载 font-awesome 并将字体添加到您的字体文件夹中,并将 font-awesome css 添加到 css 文件夹中,然后像这样调用它:
<link rel="stylesheet" href="css/font-awesome.min.css">