2017-06-14 101 views
-1

我試圖在我的項目中聲明各種形式的相同字體。我想要一個normalitalic版本的每個字體類型在相同的BrandonText名稱下。一旦我添加了italic版本,normal版本就完全被忽略了。斜體覆蓋標準?

@font-face { 
    font-family: 'BrandonText'; 
    src: url('/fonts/BrandonText-Thin.eot?#iefix') format('embedded-opentype'), 
      url('/fonts/BrandonText-Thin.otf') format('opentype'), 
      url('/fonts/BrandonText-Thin.woff') format('woff'), 
      url('/fonts/BrandonText-Thin.ttf') format('truetype'), 
      url('/fonts/BrandonText-Thin.svg#BrandonText-Thin') format('svg'); 
    font-weight: 100; 
    font-style: normal; 
} 

@font-face { 
    font-family: 'BrandonText'; 
    src: url('/fonts/BrandonText-Thin.eot?#iefix') format('embedded-opentype'), 
      url('/fonts/BrandonText-Thin.otf') format('opentype'), 
      url('/fonts/BrandonText-Thin.woff') format('woff'), 
      url('/fonts/BrandonText-Thin.ttf') format('truetype'), 
      url('/fonts/BrandonText-Thin.svg#BrandonText-Thin') format('svg'); 
    font-weight: 100; 
    font-style: italic; 
} 

這是爲什麼,有什麼辦法可以解決這個問題?

+0

什麼被忽略,在哪裏? – CBroe

+0

@CBroe在我的網站中,使用「BrandonText」(無處不在)的每種字體都是斜體,無論CSS組件中聲明瞭什麼。我希望能夠在一個字體名稱下聲明多個權重/樣式。 – Crowes

+0

@CBroe我認爲他的意思是他所有的副本現在都是斜體。 – Gezzasa

回答

1

你用凌亂重寫正常的@font-face。相反,只需聲明一次:

@font-face { 
    font-family: 'BrandonText'; 
    src: url('/fonts/BrandonText-Thin.eot?#iefix') format('embedded-opentype'), 
      url('/fonts/BrandonText-Thin.otf') format('opentype'), 
      url('/fonts/BrandonText-Thin.woff') format('woff'), 
      url('/fonts/BrandonText-Thin.ttf') format('truetype'), 
      url('/fonts/BrandonText-Thin.svg#BrandonText-Thin') format('svg'); 
    font-weight: 100; 
} 

然後,您可以對兩種情況使用相同的聲明。當你想要斜體時,只需將font-style: italic添加到元素的CSS。

0

兩者都具有相同的名稱

更改第二FONT-FAMILY宣稱: 'BrandonText';以font-family:'BrandonTextItalic';

1

你已經給出了兩個字體相同的名稱。更改爲此。

@font-face { 
    font-family: 'BrandonText'; 
    src: url('/fonts/BrandonText-Thin.eot?#iefix') format('embedded-opentype'), 
      url('/fonts/BrandonText-Thin.otf') format('opentype'), 
      url('/fonts/BrandonText-Thin.woff') format('woff'), 
      url('/fonts/BrandonText-Thin.ttf') format('truetype'), 
      url('/fonts/BrandonText-Thin.svg#BrandonText-Thin') format('svg'); 
    font-weight: 100; 
    font-style: normal; 
} 

@font-face { 
    font-family: 'BrandonTextItalic'; 
    src: url('/fonts/BrandonText-Thin.eot?#iefix') format('embedded-opentype'), 
      url('/fonts/BrandonText-Thin.otf') format('opentype'), 
      url('/fonts/BrandonText-Thin.woff') format('woff'), 
      url('/fonts/BrandonText-Thin.ttf') format('truetype'), 
      url('/fonts/BrandonText-Thin.svg#BrandonText-Thin') format('svg'); 
    font-weight: 100; 
    font-style: italic; 
}