【问题标题】:rem font-size not rendering properly in css animationrem font-size 在 css 动画中无法正确渲染
【发布时间】:2019-10-30 03:23:44
【问题描述】:

因此,我正在尝试创建一个句子,其中某些单词是动画的(循环播放) - 我认为它可以正常工作,但是当我在手机上查看该网站时,我发现了一个问题。 在桌面上(甚至在开发工具中)查看时,动画文本会以正确的大小呈现。但是,一旦我在移动设备(iPhone)上查看它,文字就会变得非常小

我也在页面上使用引导程序,所以我认为可能有些东西被覆盖了。但正如你所见,我基本上删除了所有引导类,但它仍然无法正常工作。

.animated span {
  color: #007bff;
  font-size: 0;
  opacity: 0;
  -ms-animation: topToBottom 10s infinite;
  -webkit-animation: topToBottom 10s infinite;
  animation: topToBottom 10s infinite;
}

.animated span:nth-child(2) {
  -ms-animation-delay: 2s;
  -webkit-animation-delay: 2s;
  animation-delay: 2s;
}

.animated span:nth-child(3) {
  -ms-animation-delay: 4s;
  -webkit-animation-delay: 4s;
  animation-delay: 4s;
}

.animated span:nth-child(4) {
  -ms-animation-delay: 6s;
  -webkit-animation-delay: 6s;
  animation-delay: 6s;
}

.animated span:nth-child(5) {
  -ms-animation-delay: 8s;
  -webkit-animation-delay: 8s;
  animation-delay: 8s;
}


@-webkit-keyframes topToBottom {

  0%,
  20% {
    font-size: 2.5rem;
    opacity: 1;
  }

  /* visible for 1s */
  20.01%,
  100% {
    opacity: 0;
    font-size: 0rem;
  }
<h1 class=" cover-heading animated">TribePulse replaces <br />
 <span>status updates</span>
 <span>engagement surveys</span>
 <span>progress reports</span>
 <span>status meetings</span>
 <span>EoD emails</span>
</h1>

故障演示:https://empty-cemetery.glitch.me/ 当您在桌面上查看时,所有的蓝色字迹都是正确的大小。但是,一旦您在移动设备上查看,动画文字就会变得很小。

【问题讨论】:

  • 我检查了我的手机、平板电脑、分辨率转换器、chrome、firefox 和另一部手机。它们都是相同的大小,动画文本没有变化。我认为你的手机可能有问题。
  • 奇怪...我也试过手机上的不同浏览器,但问题仍然存在

标签: html css mobile css-animations font-size


【解决方案1】:

您可以检查您的网页在移动设备上的外观和执行情况:

https://developers.google.com/web/tools/chrome-devtools/device-mode/

您还可以使用媒体查询自定义内容。标准设备的媒体查询

如果您想了解更多信息,可以访问: https://css-tricks.com/snippets/css/media-queries-for-standard-devices/

【讨论】:

  • 是的,所以当我构建网页时,我正在使用它并且一切正常。但是,一旦我在移动设备上部署并实际查看了该网页,问题就变得明显了。
  • 如果rem不工作,最好你可以试试em。参考这个网站:css-tricks.com/rem-global-em-local
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-06-01
  • 1970-01-01
  • 2014-08-24
  • 1970-01-01
  • 2019-07-21
  • 2015-03-10
  • 2020-07-04
相关资源
最近更新 更多