2016-08-26 16 views
7

Kodum, Birden çok @ font yüzünü uygulamak için daha iyi bir yol var mı?

@font-face { font-family: Affogato-Light; src: url("fonts/Affogato-Light.woff2") } 
@font-face { font-family: Affogato-Regular; src: url("fonts/Affogato-Regular.woff2") } 
@font-face { font-family: Affogato-Medium; src: url("fonts/Affogato-Medium.woff2") } 
@font-face { font-family: Affogato-Bold; src: url("fonts/Affogato-Bold.woff2") } 
@font-face { font-family: Affogato-Black; src: url("fonts/Affogato-Black.woff2") } 

birden subfonts için @font-face veya { font-family } kısa biçim var mı, yani Light, Regular vs.? Teşekkürler!

+1

'a uygularsanız Farklı ağırlıkları/stilleri tek bir yazı tipi ailesine eşlemek için bkz. Mr_Green'in cevabı. Sorunuz, hepsini tek bir @ font-face ile yüklemekse, o zaman, doğrudan CSS'de değil. – jcaron

cevap

5

Evet, var.

Style linking. sizin durumda here

, kodu şöyle dönecek hakkında daha fazla bilgiyi okuyabilirsiniz:

@font-face { 
    font-family: Affogato; 
    src: url("fonts/Affogato-Light.woff2"); 
    font-weight: 200; 
    font-style: normal; 
} 

@font-face { 
    font-family: Affogato; 
    src: url("fonts/Affogato-Regular.woff2"); 
    font-weight: 400; 
    font-style: normal; 
} 

@font-face { 
    font-family: Affogato; 
    src: url("fonts/Affogato-Medium.woff2"); 
    font-weight: 600; 
    font-style: normal; 
} 

@font-face { 
    font-family: Affogato; 
    src: url("fonts/Affogato-Bold.woff2"); 
    font-weight: 800; 
    font-style: normal; 
} 

@font-face { 
    font-family: Affogato; 
    src: url("fonts/Affogato-Black.woff2"); 
    font-weight: 900; 
    font-style: normal; 
} 

ve daha sonra elemanları için aşağıdaki sınıflar uygulayarak kullanabilirsiniz:

.u200 { 
    font-weight: 200; 
    font-style: normal; 
} 

.u400 { 
    font-weight: 200; 
    font-style: normal; 
} 

.u600 { 
    font-weight: 200; 
    font-style: normal; 
} 

.u800 { 
    font-weight: 200; 
    font-style: normal; 
} 

.u900 { 
    font-weight: 200; 
    font-style: normal; 
} 

Yazı tipini yalnızca bir kere body:

body { 
    font-family: Affogato; 
} 
İlgili konular