如何在CSS文件中导入Google Web字体? [英] How to import Google Web Font in CSS file?

查看:237
本文介绍了如何在CSS文件中导入Google Web字体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用一个CMS,我只能访问CSS文件。所以,我不能在文档的HEAD包含任何东西。我想知道是否有一种方法从CSS文件中导入Web字体?

解决方案

使用导入方法: / p>

  @import url('https://fonts.googleapis.com/css?family=Open+Sans'); 

显然,Open Sans是导入的字体。但你可以用你的代替。如果是单字字体,只需在 family = ... 之后包含字体名称,如果它是两个字,就像我一样,添加一个<$ c $

>代码行应该是您的CSS文件中的非常第一行。(感谢@Ronny指出



在Google Webfont Library中,当您决定要使用哪些字体时,它会为您提供一个包含三个选项卡的框。每个选项卡都是注入方法,HTML,CSS或JavaScript。 @import 选项卡应该为您提供css文件所需的代码。查看图片:




I'm working with a CMS which I only have access to the CSS file. So, I can't include anything thing in the HEAD of the document. I was wondering if there was a way to import the web font from within the CSS file?

解决方案

Use the import method:

@import url('https://fonts.googleapis.com/css?family=Open+Sans');

Obviously, "Open Sans" is the font that is imported. But you can replace it with yours. If it is a single word font, just include the font name after the family=... if it is two words, do as I did and add a + sign between each word.

NOTE: The @import line of code should be the very first line in your CSS file. (Thanks to @Ronny for pointing that out).

In the Google Webfont Library, when you decide upon which fonts you want to use, it gives you a box with three tabs. Each tab is an injection method, HTML, CSS or JavaScript. The @import tab should give you the code you need for css files. See image:

这篇关于如何在CSS文件中导入Google Web字体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆