如何查找,导入和使用特定字体?

时间:2019-05-11 10:58:38

标签: html css wordpress

我试图找到并导入名为if (! $request->user()->identification->verified)的字体,但是失败了,名为neontubes的字体。据我了解,我需要将freestyle script放置在style.css中,然后通过样式src进行选择 那么,不仅这两种字体类型而且所有带有.div {font-family: foobar;}的字体列表在哪里?

2 个答案:

答案 0 :(得分:1)

将所需的字体文件保存并下载到文件夹中。 在样式表中输入以下内容,

@font-face {
  font-family: "foobar";
  src: url("specify the location of your font files") format("specify font format");
}

.div {font-family: foobar};

要使用Google字体,您可以通过两种方式进行操作

链接html中的url并在css文件中提及字体系列。

link href="https://fonts.googleapis.com/css?family=*family-name*" rel="stylesheet"

并在css文件中提及以下内容

font-family: *family-name-given-in-the-link*;

第二种方法是直接在您的CSS文件中提供url

@import url('https://fonts.googleapis.com/css?family= *family-name*');

在同一个CSS文件中提及以下内容

font-family: *family-name-given-in-the-link*;

答案 1 :(得分:0)

如果您要查找字体及其在页面中的插入方式,建议您查看Google Fonts

要在链接中使用字体,您可以在<head>部分中简单链接Google的字体:

<head>
    <link href="https://fonts.googleapis.com/css?family=Tangerine" rel="stylesheet">
</head>

然后在CSS上,您只需在元素上链接字体:

YourClassHere {
    font-family: 'Tangerine', cursive;
}

如果您想直接将其放入CSS代码中,可以使用属性@import,它看起来像是这样:

YourClassHere {
    @import url('https://fonts.googleapis.com/css?family=Tangerine');
    font-family: 'Tangerine', cursive;
}

有关如何使用Google字体的更多信息: https://developers.google.com/fonts/docs/getting_started

注意 :。如果要下载字体并将其直接用于服务器/计算机上以进行离线编码,则应在CSS上使用另一个属性。

然后,在下载所需字体后,将其添加到项目文件夹中,您的CSS代码将如下所示:

  • 首先,您必须使用@font-face指定字体 属性: @ font-face {   字体家族:NameYourFontHere;   src:url(TheNameOfTheFontYouDownloadedHere.woff); //不要忘记在最后指定字体的类型 }

  • 然后您可以按照上面的方式指定字体后使用它:

    div {   字体家族:NameYourFontHere; }

@font-face规则的引用: https://www.w3schools.com/cssref/css3_pr_font-face_rule.asp

@import规则的引用: https://www.w3schools.com/cssref/pr_import_rule.asp

希望对您有帮助。

相关问题