字体加载然后闪烁以纠正字体

时间:2018-02-01 10:48:28

标签: html css wordpress fonts

我在本地加载自定义字体,但是当我的网站加载时,它似乎在闪烁到正确的字体之前显示默认字体。 实例:https://www.moneynest.co.uk/property-vs-shares/ 有人可以帮忙吗? / * Open Sans常规* / @ font-face {   font-family:" Open Sans&#34 ;;   src:url(" ./ wp-includes / fonts / OpenSans-Regular.eot"); / * IE9 Compat Modes * /   src:url(" ./ wp-includes / fonts / OpenSans-Regular.eot?#iefix")格式(" embedded-opentype"),/ * IE6-IE8 * /     url(" ./ wp-includes / fonts / OpenSans-Regular.otf")格式(" opentype"),/ * Open Type Font * /     url(" ./ wp-includes / fonts / OpenSans-Regular.svg")格式(" svg"),/ *旧版iOS * /     url(" ./ wp-includes / fonts / OpenSans-Regular.ttf")格式(" truetype"),/ * Safari,Android,iOS * /     url(" ./ wp-includes / fonts / OpenSans-Regular.woff")格式(" woff"),/ *现代浏览器* /     url(" ./ wp-includes / fonts / OpenSans-Regular.woff2")格式(" woff2"); / *现代浏览器* /   font-weight:normal;   font-style:normal; } / *使用font-converter.net转换字体。谢谢! * / @ font-face {   font-family:" Open Sans&#34 ;;   src:url(" ./ wp-includes / fonts / OpenSans-Bold.eot"); / * IE9 Compat Modes * /   src:url(" ./ wp-includes / fonts / OpenSans-Bold.eot?#iefix")格式(" embedded-opentype"),/ * IE6-IE8 * /     url(" ./ wp-includes / fonts / OpenSans-Bold.otf")格式(" opentype"),/ * Open Type Font * /     url(" ./ wp-includes / fonts / OpenSans-Bold.svg")格式(" svg"),/ *旧版iOS * /     url(" ./ wp-includes / fonts / OpenSans-Bold.ttf")格式(" truetype"),/ * Safari,Android,iOS * /     url(" ./ wp-includes / fonts / OpenSans-Bold.woff")格式(" woff"),/ *现代浏览器* /     url(" ./ wp-includes / fonts / OpenSans-Bold.woff2")格式(" woff2"); / *现代浏览器* /   font-weight:700;   font-style:bold; }

1 个答案:

答案 0 :(得分:1)

请在您的网址中添加https而不是HTTP的完整字体路径

@font-face {
  font-family: "Open Sans";
  src: url("https://www.moneynest.co.uk/wp-includes/fonts/OpenSans-Bold.eot"); /* IE9 Compat Modes */
  src: url("https://www.moneynest.co.uk/wp-includes/fonts/OpenSans-Bold.eot?#iefix") format("embedded-opentype"), /* IE6-IE8 */
    url("https://www.moneynest.co.uk/wp-includes/fonts/OpenSans-Bold.otf") format("opentype"), /* Open Type Font */
    url("https://www.moneynest.co.uk/wp-includes/fonts/OpenSans-Bold.svg") format("svg"), /* Legacy iOS */
    url("https://www.moneynest.co.uk/wp-includes/fonts/OpenSans-Bold.ttf") format("truetype"), /* Safari, Android, iOS */
    url("https://www.moneynest.co.uk/wp-includes/fonts/OpenSans-Bold.woff") format("woff"), /* Modern Browsers */
    url("https://www.moneynest.co.uk/wp-includes/fonts/OpenSans-Bold.woff2") format("woff2"); /* Modern Browsers */
  font-weight: 700;
  font-style: bold;
}

EXAMPLE