2012-01-05 2 views
0

내가 외부에서로드 된 글꼴 (예를 들어, "MyFont를")를 사용하고 그것을 여러 클래스에 사용되는 것 경우, 나는이 작업을 수행해야합니까?CSS에서 사용자 정의 외부 글꼴을 정의하는 경우이를 사용하는 모든 클래스에 대해 src를 선언해야합니까?</p> <pre><code>.one { font-family: MyFont; src: url("fonts/MyFont.ttf"); } .two { font-family: MyFont; src: url("fonts/MyFont.ttf"); } </code></pre> <p>또는 나는이 작업을 수행 할 수 있습니다

.one { font-family: MyFont; src: url("fonts/MyFont.ttf"); } 
.two { font-family: MyFont; } 

답변

2

아니,이 문서 체크 아웃 : The New Bulletproof @Font-Face Syntax

는 CSS 파일의 시작 부분에 이런 식으로 뭔가를 추가

@font-face { 
    font-family: 'MyFontFamily'; 
    src: url('myfont-webfont.eot?#iefix') format('embedded-opentype'), 
     url('myfont-webfont.woff') format('woff'), 
     url('myfont-webfont.ttf') format('truetype'), 
     url('myfont-webfont.svg#svgFontName') format('svg'); 
    } 

이 샘플 코드 실행을, 당신의 CSS의 나머지해야 다음과 같은 모습 :

.one { font-family: MyFontFamily } 
.two { font-family: MyFontFamily } 
2

@font-face 지시어를 사용해야합니다.

@font-face { 
    font-family: MyFont; 
    src: url(...); 
} 

.one { font-family: MyFont; } 
.two { font-family: MyFont; }