首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >边缘上的CSS动画变换错误

边缘上的CSS动画变换错误
EN

Stack Overflow用户
提问于 2018-07-11 06:48:47
回答 1查看 219关注 0票数 1

我有一个奇怪的bug/lag,在边缘上有一些动画,它看起来是在我添加位置之后出现的:固定在正在动画的div上,它在每个浏览器上都工作得很好,但是边缘(不确定safari tho)。

代码语言:javascript
复制
document.addEventListener('DOMContentLoaded', _ => {
  const animBoxOne = document.querySelector('.animation-box-1')
  const animBoxTwo = document.querySelector('.animation-box-2')
  
  animBoxOne.classList.add('animation-1')
  setTimeout(() => {
    animBoxOne.classList.add('hidden')
    
  }, 6000);

})
代码语言:javascript
复制
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  overflow-x: hidden;
}

.logo-box {
  display: flex !important; 
  align-items: center;
  justify-content: center;
}

.logo {
  width: 50%;
}

.animation-box-1 {
  max-height: 100vw;
  width: 900%;
  position: fixed;
}

.animation-1 {
  animation-name: introAnimation;
  animation-duration: 6s;
  animation-fill-mode: forwards;
  transition: opacity 2s;
}

.animation-box-2 {
  max-height: 100vw;
  width: 900%;

}

.square {
  width: 100vw;
  height: 100vh;
  display: block;
  float: left;
}

.square-1 {
  background: black;
}

.square-2 {
  background: #9F7324;
}

.square-3 {
  background: white;
}

.square-4 {
  background: black;
}

.hidden {
  opacity: 0;
}

@keyframes introAnimation {
  40% {
    transform: translateX(0)
  }

  55% {
    transform: translateX(-100vw)
  }

  70% {
    transform: translateX(-200vw)
  }

  85% {
    transform: translateX(-300vw);
  }

  100% {
    transform: translateX(-300vw);
  }
}

.clearfix ::after {
  content: '';
  clear: both;
}
代码语言:javascript
复制
<div class="animation-box-1 clearfix">
    <div class="square square-1 logo-box">
<!--       <img class="logo" src="logo.svg" alt=""> -->
    </div>
    <div class="square square-2"></div>
    <div class="square square-3"></div>
    <div class="square square-4"></div>
  </div>
  
  <div class="animation-box-2">
    <div class="square square-1 logo-box">
    </div>
  </div>

这是一个代码链接:https://codepen.io/matheusferraresi/pen/BVWvWg

代码语言:javascript
复制
.animation-box-1 {
max-height: 100vw;
width: 900%;
position: fixed;
}

这就是我所说的积木,有谁知道我该如何修复它吗?我需要固定位置,因为我像使用预加载器一样使用这个动画,或者有其他方法可以这样做吗?

提前谢谢。

EN

回答 1

Stack Overflow用户

发布于 2018-07-11 07:18:33

.animation-box-2添加position:fixed; z-index:-1;

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51274935

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档