两段序列帧动画播放,在ios机型上出现闪屏

使用场景:两段序列帧动画连接播放,先播放第一段播一次,再播放第二段,第二段循环播放,在ios机型上出现动画闪动,播放不正常。

错误的写法:把每一段序列帧动画单独写在了定义的动画里

css 复制代码
.gacha-bg {
  width: 750rpx;
  height: 1000rpx;
  animation: gacha 1.6s steps(22), xing 2s steps(27);
  animation-delay: 0.8s, 2.4s;
  animation-iteration-count: 1, infinite;
  animation-fill-mode: forwards, forwards;
}

@keyframes gacha {
  0% {
    background-image: url('1.jpg');
    background-size: 17250rpx;
    background-repeat: no-repeat;
    background-position: 0;
  }
  100% {
    background-image: url('1.jpg');
    background-size: 17250rpx;
    background-repeat: no-repeat;
    background-position: -16500rpx;
  }
}

@keyframes xing {
  0% {
    background-image: url('bg.jpg');
    background-size: 21000rpx;
    background-repeat: no-repeat;
    background-position: 0;
  }
  100% {
    background-image: url('bg.jpg');
    background-size: 21000rpx;
    background-repeat:no-repeat;
    background-position: -20250rpx 0;
  }
}

修改后:

背景图需要统一写一遍,由于第二段要循环播放,所以需要在定义的第二段动画里写上图片信息

css 复制代码
.gacha-bg {
  width: 750rpx;
  height: 1000rpx;
  animation: gacha 1.6s steps(22), xing 2s steps(27);
  animation-delay: 0.8s, 2.4s;
  animation-iteration-count: 1, infinite;
  animation-fill-mode: forwards, forwards;
  background-image: url('1.jpg'),url('bg.jpg');
  background-size: 17250rpx,21000rpx;
  background-repeat: no-repeat,no-repeat;
}

@keyframes gacha {
  0% {
    background-position: 0 0;
  }
  100% {
    background-position: -16500rpx 0;
  }
}

@keyframes xing {
  0% {
    background-image: url('bg.jpg');
    background-size: 21000rpx;
    background-repeat: no-repeat;
    background-position: 0 0;
  }
  100% {
    background-image: url('bg.jpg');
    background-size: 21000rpx;
    background-repeat: no-repeat;
    background-position: -20250rpx 0;
  }
}
相关推荐
强子感冒了8 分钟前
CSS基础学习:CSS选择器与优先级规则
前端·css·学习
zhyongrui1 小时前
SnipTrip 菜单 Liquid Glass 实现方案:结构、材质、交互与深浅色策略
ios·性能优化·swiftui·交互·开源软件·材质
zhyongrui1 小时前
SnipTrip 不发烫的实现路径:局部刷新 + 合成缓存 + 峰值削减
ios·swiftui
计算机毕设指导62 小时前
基于微信小程序的智能停车场管理系统【源码文末联系】
java·spring boot·微信小程序·小程序·tomcat·maven·intellij-idea
2501_933907212 小时前
如何选择西安优质小程序开发服务与本凡码农合作?
科技·微信小程序·小程序
晚霞的不甘3 小时前
Flutter for OpenHarmony 实现 iOS 风格科学计算器:从 UI 到表达式求值的完整解析
前端·flutter·ui·ios·前端框架·交互
layman052813 小时前
webpack5 css-loader:从基础到原理
前端·css·webpack
半桔13 小时前
【前端小站】CSS 样式美学:从基础语法到界面精筑的实战宝典
前端·css·html
_OP_CHEN13 小时前
【前端开发之CSS】(一)初识 CSS:网页化妆术的终极指南,新手也能轻松拿捏页面美化!
前端·css·html·网页开发·样式表·界面美化
啊哈一半醒13 小时前
CSS 主流布局
前端·css·css布局·标准流 浮动 定位·flex grid 响应式布局