【问题标题】:How to change font-family of the headers, like h2?如何更改标题的字体系列,如 h2?
【发布时间】:2021-03-06 03:33:51
【问题描述】:

这个问题有点奇怪:

我添加了一个新的字体系列,它被应用到主题中的所有地方,除了主页介绍标题。

我手动添加了一个代码(通过检查元素选择确切的类)。

.h2.text-heading-default{
    font-family: "tahome";
}

我希望它应该可以解决问题,但标题仍然显示以前的字体。

解决办法是什么?

我尝试过的东西:

  • 我在上面的代码旁边使用了“!important”
  • 清除浏览器缓存
  • 已清除 WP 缓存
  • 检查了 header.php 文件中的任何标签或冲突,没有 找到了
  • 检查了字体系列文件,它在那里并且已经被应用 到主题中的所有地方,除了介绍标题

仍然没有任何效果。

【问题讨论】:

标签: css fonts wordpress-theming


【解决方案1】:

<!DOCTYPE html>
<html>
<head>
<style>
h2.textstyle {
    font-family: tahoma
}
</style>
</head>
<body>
<h1>This is a Heading</h1>
<h2 class = "textstyle">Changing text style to tahoma</h2>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>

</body>
</html>

文本样式的名称可能有错误,它被称为“tahome”,因为我尝试过,它不起作用,但是当我在 html 中执行上述代码时,对于“tahoma”它起作用了.

【讨论】:

    【解决方案2】:

    也许 header 在 font-family css 中有一个“!important”标签。如果是这样,您可以删除标题 css 中的“!important”单词或将“!important”添加到您的班级

    【讨论】:

    • header.php 文件中没有“!important”。 style.css 文件也一样。我正在使用 Visual Composer 顺便说一句
    【解决方案3】:

    很多人已经回答了,但让我再次告诉你,你需要添加 !important 。如果这不起作用,请尝试简化代码。

    .h2 /* Try writing this only*/ {
    font-family: "tahome" !important;
    

    }

    还要检查 HTML 代码中是否有任何错误。您可以将 HTML 代码发布到 Stackoverflow 中进行重新检查。

    是的,我不太确定,但如果这不起作用,可能是您安装的字体系列不支持标题。尝试下载其他 font=family。

    再见。祝你有美好的一天!

    【讨论】:

      【解决方案4】:
      .h2.text-heading-default {
        font-family: 'tahome' !important;
      }
      

      只需在字体系列名称前添加 '!important'。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-05-19
        • 1970-01-01
        • 1970-01-01
        • 2014-01-17
        • 1970-01-01
        • 2011-05-23
        相关资源
        最近更新 更多