gpt4 book ai didi

android - Ionic Framework Android 构建中的@font-face 加载问题

转载 作者:行者123 更新时间:2023-11-28 07:21:02 25 4
gpt4 key购买 nike

我在 Ionic Framework 中开发应用程序时遇到了一个非常奇怪的问题。

Screenshot of issue

我正在将 @font-face 导入到我的 Ionic Framework 应用程序中,然后在 Android 设备 (Galaxy SIII) 上运行该应用程序。正如您所看到的,字体 (Montserrat) 在除图像下方(和初始屏幕)之外的任何地方都加载。它们在网络预览中加载良好。它们在使用系统字体(本例中为“Robot”)时也能正常加载。我想知道这是否是由于未预加载字体以供立即使用以及 DOM 在将字体加载到这些特定元素上之前呈现而引起的。

我已经将背景设置为红色,红色 block 出现了,所以实际内容正在传递,但看起来文本没有呈现。文本是纯 HTML 格式。但我也通过表达式注入(inject)它,看看是否有任何效果。它没有。 ionic 图标的导入字体也可以完美运行。

这是我认为最好的提示...如果我滑动屏幕,瞧,文本会神奇地出现。在此之后,它不会在其他任何地方再次发生。

我包含了我的 CSS @font-face 以防万一我遗漏了什么......

  @font-face {
font-family: 'montserratregular';
src: url('montserrat-regular-webfont.eot#montserratregular');
src: url('montserrat-regular-webfont.eot?#iefix') format('embedded-opentype'),
url('montserrat-regular-webfont.woff2#montserratregular') format('woff2'),
url('montserrat-regular-webfont.woff#montserratregular') format('woff'),
url('montserrat-regular-webfont.ttf#montserratregular') format('truetype'),
url('montserrat-regular-webfont.svg#montserratregular') format('svg');
font-weight: normal;
font-style: normal;
}

* {
font-family: 'montserratregular', 'Helvetica Neue', 'Arial', sans-serif!important;
font-weight: normal !important;
}

...和相应的 HTML

<div ng-click="testTime()" class="fullwidth-container start-test begin" ng-if="reactionFrame === 0">
<img src="img/touch.svg" class="tap-icon">
<h1 class="test-prompt">Tap to begin</h1>
<h3>Please follow the instructions on the next screen as quickly as possible.</h3>
</div>

有谁知道为什么会发生这种情况,如果是这样,解决方案是什么?

最佳答案

经过大量试验和错误后,我最终将问题追溯到默认 Ionic 样式表中包含的 css。特别是这些样式(通过排除此 block ,它解决了问题 - 但从未孤立于一种样式):

.content {
position: relative; }

.scroll-content {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
overflow: hidden;
margin-top: -1px;
padding-top: 1px;
margin-bottom: -1px;
width: auto;
height: auto; }

.menu .scroll-content.scroll-content-false {
z-index: 11; }

.scroll-view {
position: relative;
display: block;
overflow: hidden;
margin-top: -1px; }

似乎滚动状态导致字体加载延迟。我没有更改 Ionic.css 文件,而是禁用了 <ion-content> 上的滚动。和 <ion-pane>通过实现 <ion-content scroll="false"><ion-pane scroll="false"> , 分别。文本现在可以完美加载。

关于android - Ionic Framework Android 构建中的@font-face 加载问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32085912/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com