0

@font-face設計中のサイトでカスタム フォントを使用しようとしています。今回はなぜ機能しないのかわかりません。以前は問題なく使用していました。

これが私のコードです(実際のサイトからではなく、問題をテストするために使用した簡略化されたバージョンです):

html

<!DOCTYPE html>
<html>
<head>
<title>My Page</title>
<link rel="stylesheet" type="text/css" href="./css/stylesheet.css">
</head>
<body>
<p>Loremm ipsum</p>
</body>
</html>

css(リセットは残しました)

/*--------------------------*/
/*----------RESET-----------*/
/*--------------------------*/

/* http://meyerweb.com/eric/tools/css/reset/ 
   v2.0 | 20110126
   License: none (public domain)
*/

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
    margin: 0;
    padding: 0;
    border: 0;
    font-size: 100%;
    font: inherit;
    vertical-align: baseline;
    font-family:myfont;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure, 
footer, header, hgroup, menu, nav, section {
    display: block;
}
body {
    line-height: 1;
}
ol, ul {
    list-style: none;
}
blockquote, q {
    quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
    content: '';
    content: none;
}
table {
    border-collapse: collapse;
    border-spacing: 0;
}

/*-------------------------*/
/*-----------MAIN----------*/
/*-------------------------*/

@font-face {
    font-family:myfont;
    src:url('./fonts/myfont.ttf'),
        url('./fonts/myfont.eot');
}

私のindex.htmlはhtml/

私のフォントファイルはhtml/fonts/

私のcssはhtml/css/

誰でも問題を見ることができますか?

これをクロムとファイアフォックスでテストしましたが、編集用にコンピューター上にあります。

4

2 に答える 2

0

@font には常に問題がありました。うまくいけば、これはあなたを助けるでしょう.

style.css (ota、woff、ttf、および svg フォント タイプを取得します)。HTML に指定された指示に従ってフォントを見つけることができることを確認してください。たとえば、html/fonts/ にある場合、URL は fonts/blah.eot にする必要があります。

 @font-face {
     font-family:'Carrosserie-Medium';
     src: url('../webfonts/FAFC3_0.eot');
     src: url('../webfonts/FAFC3_0.eot?#iefix') format('embedded-opentype'), url('../webfonts/FAFC3_0.woff') format('woff'), url('../webfonts/FAFC3_0.ttf') format('truetype'), url('../webfonts/FAFC3_0.svg#wf') format('svg');
 }
 @font-face {
     font-family:'Carrosserie-Thin';
     src: url('../webfonts/FAFC3_1.eot');
     src: url('../webfonts/FAFC3_1.eot?#iefix') format('embedded-opentype'), url('../webfonts/FAFC3_1.woff') format('woff'), url('../webfonts/FAFC3_1.ttf') format('truetype'), url('../webfonts/FAFC3_1.svg#wf') format('svg');
 }
.Carrosserie-Medium {
    font-family: Carrosserie-Medium;
    font-weight: normal;
    font-style: normal;
}
.Carrosserie-Thin {
    font-family: Carrosserie-Thin;
    font-weight: normal;
    font-style: normal;
}

実装する

h2#tagline {font-size:30px;font-family:'Carrosserie-Thin', sans-serif; }

HTML

<h2 id="tagline">Try this.</h2>
于 2013-04-07T13:34:08.537 に答える