私自身、これまで何度も悩みました。HTML/CSS ファイルに関連して、ルート フォルダーと比較して、フォント ファイルをダウンロードした場所を確認します。
たとえば、すべてのフォントがルート フォルダーの同じ場所にある場合、上記のコードは正しいです。
他に 2 つのシナリオが発生する可能性があります。1 つ目は、ルート内のフォルダーにあるfontsという名前の新しく作成されたフォルダーにそれらをダウンロードした場合、コードは次のようになります。
@font-face {
font-family: 'font-icon';
src: url('fonts/richstyle-webfont.eot') format('eot');
src: url('fonts/richstyle-webfont.eot?#iefix') format('embedded-opentype'),
url('fonts/richstyle-webfont.woff') format('woff'),
url('fonts/richstyle-webfont.ttf') format('truetype'),
url('fonts/richstyle-webfont.svg#richstylemedium') format('svg');
font-weight: normal;
font-style: normal;
}
もう 1 つのシナリオは、ファイルが Web サイトのルート ディレクトリ内の別のフォルダーにあるが、フォント ファイルが完全に別のフォルダーにあるフォントにある場合です。アクセスする方法は、次のように別の相対リンクを作成することです。
@font-face {
font-family: 'font-icon';
src: url('../fonts/richstyle-webfont.eot') format('eot');
src: url('../fonts/richstyle-webfont.eot?#iefix') format('embedded-opentype'),
url('../fonts/richstyle-webfont.woff') format('woff'),
url('../fonts/richstyle-webfont.ttf') format('truetype'),
url('../fonts/richstyle-webfont.svg#richstylemedium') format('svg');
font-weight: normal;
font-style: normal;
}
コード内で URL ソースをどのように指すかによって異なります。私が言ったように、私はこれまで何度もこの問題を抱えてきました。最初にこれを試して、それが役立つかどうかを確認してください。
あなたができる他のことは、この人が彼の答えに投稿したのと同じことをすることです: @font-face works in IE8 but not IE9
彼はまた、この smileyface-local:src: local("☺"),
をコードに追加したので、コードは次のようになります。
@font-face {
font-family: 'font-icon';
src: url('fonts/richstyle-webfont.eot');
src: local("☺"); <-- should've been a semi-colon
src: url('fonts/richstyle-webfont.eot?#iefix') format('embedded-opentype'),
url('fonts/richstyle-webfont.woff') format('woff'),
url('fonts/richstyle-webfont.ttf') format('truetype'),
url('fonts/richstyle-webfont.svg#richstylemedium') format('svg');
font-weight: normal;
font-style: normal;
}
以下は、コードを書き出すためのより良い方法です。これを試して、どのように機能するかを確認してください。
@font-face {
font-family: 'font-icon';
src: local("☺"),
url('fonts/richstyle-webfont.eot') format('eot'),
url('fonts/richstyle-webfont.eot?#iefix') format('embedded-opentype'),
url('fonts/richstyle-webfont.woff') format('woff'),
url('fonts/richstyle-webfont.ttf') format('truetype'),
url('fonts/richstyle-webfont.svg#richstylemedium') format('svg');
font-weight: normal;
font-style: normal;
}
お役に立てれば!