我試圖爲我的網站設置自定義字體,但它在Firefox,Chrome或Edge/IE上都不起作用。 Firefox開發人員工具中的網絡部分表示未找到字體並列出了404,儘管這些網址應該是正確的。這是我的代碼:@ font-face在字體上返回404s
@font-face {
font-family: 'Raleway55';
src: url('/wp-content/uploads/font-organizer/RalewayRegular.ttf') format('truetype'),
url('/wp-content/uploads/font-organizer/ralewayregular-webfont.woff') format('woff'),
url('/wp-content/uploads/font-organizer/ralewayregular-webfont.woff2') format('woff2');
font-weight: normal;
}
@font-face {
font-family: 'Raleway55';
src: url('/wp-content/uploads/font-organizer/Raleway-Light.ttf') format('truetype');
font-weight: 300;
}
@font-face {
font-family: 'Raleway55';
src: url('/wp-content/uploads/font-organizer/Raleway-LightItalic.ttf') format('truetype');
font-weight: 300;
font-style: italic;
}
@font-face {
font-family: 'Raleway55';
src: url('/wp-content/uploads/font-organizer/Raleway-Italic.ttf') format('truetype');
font-style: italic;
}
@font-face {
font-family: 'Raleway55';
src: url('/wp-content/uploads/font-organizer/Raleway-SemiBold.ttf') format('truetype');
font-weight: 600;
}
@font-face {
font-family: 'Raleway55';
src: url('/wp-content/uploads/font-organizer/Raleway-SemiBoldItalic.ttf') format('truetype');
font-weight: 600;
font-style: italic;
}
@font-face {
font-family: 'Raleway55';
src: url('/wp-content/uploads/font-organizer/Raleway-Bold.ttf') format('truetype');
font-weight: 700;
}
@font-face {
font-family: 'Raleway55';
src: url('/wp-content/uploads/font-organizer/Raleway-BoldItalic.ttf') format('truetype');
font-weight: 700;
font-style: italic;
}
@font-face {
font-family: 'Raleway55';
src: url('/wp-content/uploads/font-organizer/Raleway-ExtraBold.ttf') format('truetype');
font-weight: 800;
}
@font-face {
font-family: 'Raleway55';
src: url('/wp-content/uploads/font-organizer/Raleway-ExtraBoldItalic.ttf') format('truetype');
font-weight: 800;
font-style: italic;
}
body { font-family: 'Raleway55'!important; font-weight:normal!important; }
h1 { font-family: 'Raleway55'!important; font-weight:normal!important; }
h2 { font-family: 'Raleway55'!important; font-weight:normal!important; }
h3 { font-family: 'Raleway55'!important; font-weight:normal!important; }
h4 { font-family: 'Raleway55'!important; font-weight:normal!important; }
h5 { font-family: 'Raleway55'!important; font-weight:normal!important; }
h6 { font-family: 'Raleway55'!important; font-weight:normal!important; }
p { font-family: 'Raleway55'!important; font-weight:normal!important; }
q { font-family: 'Raleway55'!important; font-weight:normal!important; }
li { font-family: 'Raleway55'!important; font-weight:normal!important; }
a { font-family: 'Raleway55'!important; font-weight:normal!important; } <code>
你能幫忙嗎?謝謝!
嘗試從'/ wp-content /'中刪除'/'。 –
另外,不是聲明所有的元素font-family,而是使用'* {font-family:'Raleway55';}'。不要將其設置爲重要的,否則稍後將難以改變。 –
最後一件事,如果樣式表位於文件夾中,則可以使用URL前面的「../」來表示父文件夾。假設'wp-content/stylesheets'和你的字體是'wp-content/fonts',那麼你可以輸入'../ fonts/myfont.fontExtension'。 –