[英]How to change website font using Bootstrap CDN
I am trying to change the font of my website but I am not able to access the 'bootstrap.css' file since I am using Bootstrap CDN. 我正在尝试更改网站的字体,但由于使用的是Bootstrap CDN,因此无法访问“ bootstrap.css”文件。 Is there any way to access 'bootstrap.css' while still using Bootstrap CDN or do I have to install the complied Bootstrap files?
在仍然使用Bootstrap CDN的情况下,有什么方法可以访问“ bootstrap.css”,还是我必须安装编译后的Bootstrap文件?
I've tried changing the 'font-family' in my 'main.css' file but that did not seem to do anything. 我已经尝试过在“ main.css”文件中更改“字体家族”,但这似乎无济于事。
body {
background: #fafafa;
color: #333333;
margin-top: 5rem;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif !important;
}
Make sure when you include the stylesheets, main.css comes AFTER bootstrap like so: 确保当包含样式表时,main.css会在自举后出现,如下所示:
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="main.css">
In main.css, create a rule for the selectors you wish to overwrite 在main.css中,为要覆盖的选择器创建一个规则
body {
font-family: "Times New Roman";
}
If I have trouble verifying that the fonts are working, I will often pick out an obviously different font so the changes are easy to see and to ensure that there is not a problem with specificity or something else. 如果无法验证字体是否正常工作,我通常会选择明显不同的字体,以便可以轻松看到所做的更改并确保特定性或其他方面没有问题。 After problems are figured out, I'll switch back to the real font I wanted to use.
解决问题后,我将切换回想要使用的实际字体。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.