2017-06-14 57 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; 
}