css - 无法让字体在 wordpress 上工作

标签 css wordpress fonts

我快要疯了,因为我的网站使用自定义网络字体,现在突然停止工作了。

我从 Font Squirrel 获得了网络字体套件,我正在使用我的本地 WP 站点对其进行测试。

我将字体包粘贴到 wp-content/themes/twentyfifteen/fonts/

这是主题文件夹中我的 style.css 的内容

@font-face {
font-family: 'quicksandregular';
src: url('/fonts/quicksand-regular-webfont.woff2') format('woff2'),
     url('/fonts/quicksand-regular-webfont.woff') format('woff');
font-weight: normal;
font-style: normal;

}

h { 
font-family: 'quicksandregular' !important;
}

并且网页中没有任何反应。我看不到我的自定义字体 Bebas Neue。

任何帮助将不胜感激。

问候。

最佳答案

你的意思是贴“quicksand”这个字体族?无论如何,这应该是一个很好的导入新字体的模板。

@font-face {
    font-family: 'quicksandregular';
    src: url('/htdocs/www/wp-content/themes/twentyfifteen/fonts/quicksand-regular-webfont.woff2') format('woff2'),
         url('/htdocs/www/wp-content/themes/twentyfifteen/fonts/quicksand-regular-webfont.woff') format('woff');
    font-weight: normal;
    font-style: normal;
}

然后,当您调用字体时,需要在具有有效名称的有效选择器中完成,即:

/* Style all Headlines */
h1, h2, h3, h4, h5, h6{
    font-family: "quicksandregular";
}

您还应该像这样使用后备字体堆栈:

/* Style all Headlines */
h1, h2, h3, h4, h5, h6{
    font-family: "quicksandregular", Arial, Helvetica, sans-serif;
}

关于css - 无法让字体在 wordpress 上工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40728426/

相关文章:

javascript - 将 JS 窗口高度嵌入到 CSS?

html - 使用 CSS 包含自定义字体以使其与大多数浏览器兼容的最佳方法是什么?

java - 将自定义字体导入 JSF

css - 使用 CSS 列并确保直接子项的内容不换行

wordpress - 使用 Wordpress 和 JSON REST API 插件设置 Ember-Data DS.RESTadapter

javascript - javascript 文件中带有 php (wordpress) 的 Src 文件路径

wpf - 使用带有 WPF 标签的 System.Drawing.Font

javascript - 像选取框一样生成动画

html - 如何使我的 DIV 与它所包含的文本大小相同

html - 三列布局中的动态宽度第三列