我正在使用CMS,我只能访问CSS文件。因此,我不能在文档的<head>中包含任何内容。我想知道是否有一种方法可以从CSS文件中导入web字体?


当前回答

请登录https://fonts.google.com/ 点击+添加字体 去选择字体>嵌入> @IMPORT >复制url和粘贴在你的。css文件上面的主体标签。 这是完成了。

其他回答

请登录https://fonts.google.com/ 点击+添加字体 去选择字体>嵌入> @IMPORT >复制url和粘贴在你的。css文件上面的主体标签。 这是完成了。

使用@import标记

@import url('http://fonts.googleapis.com/css?family=Kavoon');
<link href="https://fonts.googleapis.com/css?family=(any font of your 
choice)" rel="stylesheet" type="text/css">

要选择字体,您可以访问链接:https://fonts.google.com

写你选择的字体名称从网站排除括号。

举个例子,你选择了龙虾字体,

<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" 
type="text/css">

然后你就可以在整个HTML/CSS文件中使用它作为字体族了。

例如

<h2 style="Lobster">Please Like This Answer</h2>
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Open+Sans:300,400,600,700&amp;lang=en" />

最好不要使用@import。只需要在布局的头部使用link元素,如上图所示。

通过链接就可以了

https://developers.google.com/fonts/docs/getting_started

将其导入样式表使用

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