简体   繁体   English

NextJS 关键帧

[英]NextJS Keyframes

I created a background with 3 images using keyframes.我使用关键帧创建了一个包含 3 个图像的背景。 I first created the project just using html and css, but now I'm trying to create my project using NextJS.我首先使用 html 和 css 创建了项目,但现在我正在尝试使用 NextJS 创建我的项目。

In the html/css version, this transition is working fine, but in NextJS the 3th image won't show, I get a white screen, the fist two however work fine.在 html/css 版本中,此转换工作正常,但在 NextJS 中,第 3 个图像不会显示,我得到一个白屏,但第 2 个工作正常。

Can anybody help me with this please?有人可以帮我吗? Please find added my code:请找到添加我的代码:

.mainheader {
  height: 100vh;
  position: relative;
  color: #fff;
  animation: animate ease-in-out 10s infinite;
  background-size: cover;
}
@keyframes animate {
  0%,
  100% {
    background-image: url(../assets/afbeeldingen/bg-3.jpg)
      url(../assets/afbeeldingen/bg-1.jpg);
  }
  33% {
    background-image: url(../assets/afbeeldingen/bg-1.jpg),
      url(../assets/afbeeldingen/bg-2.jpg);
  }
  66% {
    background-image: url(../assets/afbeeldingen/bg-2.jpg),
      url(../assets/afbeeldingen/bg-3.jpg);
  }
}

First, I dont know if this applies to your case since you didnt provide a link or snippet to your problem code.首先,我不知道这是否适用于您的情况,因为您没有提供问题代码的链接或代码段。 I was experiencing the same problems with a slideshow css animation .我在使用幻灯片 css animation时遇到了同样的问题。

#slideset1 > * {
    position: absolute;
    height: 10rem;
    top: 0;
    left: -22.5rem;
    animation: 12s autoplay1 infinite ease-in-out;
}

The HTML/CSS code works on codepen, but when transferred to nextjs environment it just didnt animate. HTML/CSS 代码在 codepen 上工作,但是当转移到 nextjs 环境时,它只是没有动画。 After trying various suggestions, what resolved it was this from Alex Galays .在尝试了各种建议后, Alex Galays 解决了这个问题 To not use the shorthand for the animation property but to specify each animation property that you use separately.不要使用 animation 属性的简写,而是指定您单独使用的每个 animation 属性。

#slideset2 > * {
  position: absolute;
  height: 10rem;
  top: 25rem;
  left: 0;
  animation-duration: 12s;
  animation-name: autoplay2;
  animation-iteration-count: infinite;
  animation-timing-function: ease-in-out;
}

You can see it working here on codesandbox Cant/didnt test with your case, but you can apply it to your own code.您可以在此处看到它对您的案例的代码和框 Cant/didnt测试工作,但您可以将其应用于您自己的代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM