我有一个想要在我的应用程序中使用的自定义字体。
字体名称为myfont,扩展名为(myfont.eot,.myfont.svg,myfont.ttf,myfont.woff,myfont.woff2)的文件,在我进行cordova构建时将它们复制到IOS和android资产文件夹中。但是,当我在设备上打开应用程序时,看不到新的字体显示。
当我从Mac上的Safari浏览器运行应用程序时,确实看到了新的显示形式。
这是我的CSS文件中的代码段
html, body {
overflow-x: hidden;
-webkit-tap-highlight-color: rgba(0,0,0,0);
font-family: 'myfont';
font-size: 16px;
}
为了在Android和iOS设备上看到这种新字体,我还需要做些其他事情吗?
谢谢
@font-face
在CSS中使用。
@font-face {
font-family: "my-font";
src: url("../assets/myfonts.ttf"); // Give relative path to your css file.
}
在顶部将代码添加到您的css文件中。然后,您可以my-font
在任何需要的地方轻松使用字体系列。
例:
的CSS
.class-myfont {
font-family: my-font;
}
的HTML
<span class="class-myfont">Hello there</span>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句