【发布时间】:2022-01-29 23:30:28
【问题描述】:
所以我使用 @import 在我的 CSS 文件中导入了 2 种字体(Roboto 和 Shrikhand)
我希望页面中的文本(段落<p>)使用 Roboto,我的标题(标题<h1>, <h2>...<h6>)使用 Shrikhand
这是我的 CSS 代码
/*Roboto font importation for text*/
@import url("https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,600;1,700");
/*Shrikhand font importation for titles*/
@import url("https://fonts.googleapis.com/css2?family=Shrikhand:ital,wght@0,600;1,700");
body{
box-sizing: border-box;
margin: 0;
font-family: 'Roboto', 'Shrikhand';
}
.main__heading{
font-family: 'Shrikhand';
}
.main__text{
font-family: 'Roboto';
}
但只有文本是 Roboto,标题是默认字体(Times new roman)。而且我不知道该怎么做才能改变他们的字体。
我们将不胜感激。
【问题讨论】:
-
我们可以看到 HTML.. 那里的类名正确吗?
-
您的两个导入链接都已损坏(有关详细信息,请参阅我的答案),这意味着到目前为止,您还没有从谷歌导入任何字体。另请注意,损坏的谷歌字体导入也会影响后续字体。