简体   繁体   English

外部CSS + Google字体

[英]External CSS + Google font

For some reason, the Google font that is imported doesn't work? 由于某种原因,导入的Google字体不起作用? The font isn't displayed correctly. 字体显示不正确。 Here is the HTML. 这是HTML。

<!DOCTYPE html>
<html>
<head>
  <title>Test</title>
  <link href='https://fonts.googleapis.com/css?family=Pacifico' rel='stylesheet' type='text/css'>
  <link href="/main.css" rel=stylesheet type="text/css">
</head>
<body>
  <div class="testing">
   <h1>nothing to see</h1>
  </div>
</body> 
</html>

My CSS file: 我的CSS文件:

.testing h1 {
font-family: 'Pacifico';
font-style: normal;
}

The problem is that the second link tag(the one containing main.css) has the wrong address to main.css. 问题是第二个链接标记(包含main.css的那个)的main.css地址错误。 Try putting main.css in the same folder as your HTML file and delete the slash(/) right next to the href value main.css as shown 尝试将main.css放在与HTML文件相同的文件夹中,并删除href值main.css旁边的斜杠(/),如图所示

<link href="main.css" rel=stylesheet type="text/css">

If you want your CSS inside of a seperate file insert the code as shown 如果要将CSS放在单独的文件中,请插入代码,如下所示

<link href="(FILE NAME)/main.css" rel=stylesheet type="text/css">

为main.css使用正确的路径制作css文件夹并将主css文件放入该文件夹并在以下路径中使用

<link href="css/main.css" rel=stylesheet type="text/css">

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

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