简体   繁体   English

CSS @ font-face无法正常工作(第二期)

[英]CSS @font-face is not working properly (2nd Issue)

When I use my computer with Firefox or IE, the font doesn't work, only when using Chrome. 当我在Firefox或IE上使用计算机时,该字体仅在使用Chrome时不起作用。 Also, when I use my cellphone even with chrome, the font doesn't work. 另外,当我即使在使用镀铬手机时也无法使用该字体。

Please consider my code below, with a huge help from Gerardo BLANCO. 在Gerardo BLANCO的巨大帮助下,请考虑以下我的代码。

 @font-face { font-family: Signika; src: url('cllean-directory/fonts/Signika-Regular.ttf') format('truetype'), url('cllean-directory/fonts/Signika-Regular.woff') format('woff'), url('cllean-directory/fonts/Signika-Regular.woff2') format('woff2'); font-weight: normal; font-style: normal; } @font-face { font-family: Signika; src: url('cllean-directory/fonts/Signika-Bold.ttf') format('truetype'), url('cllean-directory/fonts/Signika-Bold.woff') format('woff'), url('cllean-directory/fonts/Signika-Bold.woff2') format('woff2'); font-weight: bolder; font-style: normal; } @font-face { font-family: Signika; src: url('cllean-directory/fonts/Signika-Light.ttf') format('truetype'), url('cllean-directory/fonts/Signika-Light.woff') format('woff'), url('cllean-directory/fonts/Signika-Light.woff2') format('woff2'); font-weight: lighter; font-style: normal; } @font-face { font-family: Signika; src: url('cllean-directory/fonts/Signika-Semibold.ttf') format('truetype'), url('cllean-directory/fonts/Signika-Semibold.woff') format('woff'), url('cllean-directory/fonts/Signika-Semibold.woff2') format('woff2'); font-weight: bold; font-style: normal; } font-family: SignikaS; } 

Few mistakes on your part. 您很少犯错误。 1) It is better to name all of you font families as one. 1)最好将所有字体家族都命名为一个。 2) You need to declare its respective weight and style. 2)您需要声明其各自的重量和样式。 3) Personal one -> Always put the family first 3)个人的->始终把家庭放在首位

Hope this helps 希望这可以帮助

 @font-face { font-family: Signika; src: url('fonts/Signika-Regular.ttf') format('truetype'), url('fonts/Signika-Regular.woff') format('woff'), url('fonts/Signika-Regular.woff2') format('woff2'); font-weight: normal; font-style: normal; } @font-face { font-family: Signika; src: url('fonts/Signika-Bold.ttf') format('truetype'), url('fonts/Signika-Bold.woff') format('woff'), url('fonts/Signika-Bold.woff2') format('woff2'); font-weight: bold; font-style: normal; } p { font-family: Signika; } 
 <p>Hi</p> <p style="font-weight:bold">Hi</p> 

Use semi-colons ex:- 使用分号,例如:

@font-face {
  font-family: 'Signika';
  font-style: normal;
  font-weight: 400;
  src: url('../fonts/signika-v8-latin-regular.eot'); /* IE9 Compat Modes */
  src: local('Signika Regular'), local('Signika-Regular'),
       url('../fonts/signika-v8-latin-regular.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
       url('../fonts/signika-v8-latin-regular.woff2') format('woff2'), /* Super Modern Browsers */
       url('../fonts/signika-v8-latin-regular.woff') format('woff'), /* Modern Browsers */
       url('../fonts/signika-v8-latin-regular.ttf') format('truetype'), /* Safari, Android, iOS */
       url('../fonts/signika-v8-latin-regular.svg#Signika') format('svg'); /* Legacy iOS */
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM