我快要疯了,因为我的网站使用自定义网络字体,现在突然停止工作了。
我从 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/