4

我正在尝试将 PT Sans 添加到时事通讯中,但由于某种原因它没有加载我已经复制了几乎所有的代码,但它不起作用。我会非常感谢任何可以提供帮助的人。

这是CSS代码:

h1, h2, h3 {
    font-family: 'PT Sans', sans-serif;
}

和 HTML 代码:

<link href="http://fonts.googleapis.com/css?family=PT+Sans" rel="stylesheet" type="text/css">

编辑:这是CSS的其余部分:

h1, h2, h3 {
    font-family: 'PT Sans', sans-serif;
}

#logo{width:810px}

#saveDateText{
    position:relative;
    top:30px;
    left:80px;
    font-size:50px;
    color:rgb(228,242,214)
}

#october{
    position:relative;
    top:0px;
    left:90px;
    font-size:35px;
    color:rgb(228,242,214)
}

#raftLogo{
    position:relative;
    top:-125px;
    left:550px;
}

#saveTheDate {
    background-color:rgb(123, 190, 48);
    height:170px;
    width:810px;
}

#honoring {
    position:relative;
    background-color:rgb(9, 65, 30);
    width:810px;
    top:-30px;
    font-size:20px;
    height:400px;
}

#honoringTextDiv {
    position:relative;
    width:740px;
    left:70px;
    top:50px
}

#infoText {
    color:white;
    font-size:25px;
}

#honoringText {
    color:rgb(242, 183, 51);
}

#benifit{
    color:white;
    font-size:25px
}

#morgridge {
    position:relative;
    top:20px
}
#sponsorships {
    position:relative;
    left:20px;
    top:-30px;
    height:300px;
    width:400px;
    border-right-style:solid;
    border-right-color:rgb(160, 202, 129);
    border-right-width:1px;
}

#inventiveSponsorsDiv {
    position:relative;
    left:425px;
    top:-155px
}
#dmns {
    position:relative;
    top:-40px;
}
#1stbank {
    position:relative;
    top:80px;
}

#inspirationalSponsors, #inventiveSponsors{
    position:relative;
    top:0px;
    color:rgb(123,190,48);
    font-size:18px;
}
#inventiveSponsors {
    top:-20px;
}

#names, #names2 {
    line-height:25px;
    font-size:14px

}
#names2 {
    position:relative;
    top:-94px;
    left:160px;
    text-align:left;
}
4

6 回答 6

14

尝试使用不带“http”的 URL:

<link href="//fonts.googleapis.com/css?family=PT+Sans" rel="stylesheet" type="text/css">
于 2015-02-02T12:05:24.557 回答
4

小贴士:
1. 使用 HTML 代码在你的<head>. 示例:
<head> <link href='http://fonts.googleapis.com/css?family=PT+Sans' rel='stylesheet' type='text/css'> /* Rest of the code after this */ </head>
2. 如果这不起作用,请将其放入您的 CSS 文件中: @import url(http://fonts.googleapis.com/css?family=PT+Sans);

于 2013-07-17T23:40:05.067 回答
2

问问自己这个:

1. Are you developing online or offline (if online check number 2)

2. Make sure your browser does not have a shield icon because this 
   means the browser is blocking the font and you need to click
   the allow button.

3. Check for spelling errors or anything suspicious.

4. Finally @import is the safest way I think. 
于 2014-03-30T21:17:05.173 回答
0

检查您的 css 文件是否在供应商样式表之后加载。例如, bootstrap.css 应该在您的 css 文件之前。

于 2019-04-17T09:16:29.793 回答
0

我有同样的问题,如果使用 CSS 标签:

“字体:3em 粗体;” ---这会覆盖 google api 调用并加载您的下一个默认字体。

解决方案:使用字体样式和字体大小

于 2017-12-09T17:16:45.583 回答
-1

我今天遇到了这个问题。如果您使用 httpsurl 进行测试,则需要将链接更改href="http://fonts.googleapis.com/css?family=PT+Sans" rel="stylesheet"href="https://fonts.googleapis.com/css?family=PT+Sans" rel="stylesheet". 否则,就会出现冲突问题。

我希望这会希望有人。

于 2020-01-07T05:19:07.533 回答