Google字体不适用于Bootstrap

发布于 2025-02-06 22:39:00 字数 425 浏览 2 评论 0原文

这是我的Google字体链接:

<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@100;400;900&display=swap" rel="stylesheet">

这是我的CSS代码:

h1{
    font-family: 'Montserrat', sans-serif;
    font-weight: 900;
}

this is my google fonts links:

<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@100;400;900&display=swap" rel="stylesheet">

and this is my css code:

h1{
    font-family: 'Montserrat', sans-serif;
    font-weight: 900;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

腻橙味 2025-02-13 22:39:01

您可以将其直接添加到CSS中:

@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@200;300&display=swap');

h1{
    font-family: 'Montserrat', sans-serif;
    font-weight: 900;
}

如果它不起作用,则必须查看Bootstrap是否没有覆盖这些值,因此您必须添加!重要,例如:

h1{
    font-family: 'Montserrat', sans-serif!important;
    font-weight: 900;
}

You can add it directly in CSS like:

@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@200;300&display=swap');

h1{
    font-family: 'Montserrat', sans-serif;
    font-weight: 900;
}

If it doesn't work you have to see if bootstrap is not overwriting those values so you have to add !important there like:

h1{
    font-family: 'Montserrat', sans-serif!important;
    font-weight: 900;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文