简体   繁体   English

为什么我的 Image animation 代码不起作用?

[英]Why does my Image animation code not work?

I'm working on an animation with css and html but my animation isn't working.我正在使用 animation 与 css 和 html 但我的 Z6F1C25ED1523962F1BBF9DEE9BE 不工作。

https://www.abroprojectafbouw.nl/ https://www.abroprojectafbouw.nl/

Here is an example how it should look if its done (you need to scroll down) and here is my code.这是一个示例,如果完成(您需要向下滚动),它应该如何看待,这是我的代码。 The black screen is always jumping back.黑屏总是跳回来。 Thank you for Help!谢谢你的帮助!

 html, body { height: 100vh; } body { margin: 0; width: 100%; }.image { animation: change 0.5s ease-out; height: 70vw; }.img { background-image: url("https://www.abroprojectafbouw.nl/wp-content/uploads/moddit-fly-images/468/foto-15-scaled-770x500-c.jpg"); background-size: cover; position: relative; width: 100%; height: 70vw; }.overlay { position: absolute; width: 100%; height: 70vw; background-color: #000; top: 0; right: 0; animation: slide 0.5s ease-out; animation-delay: 0.6s; } @keyframes slide { 0% { left: 0; } 100% { left: 100%; } } @keyframes change { 0% { width: 0%; } 100% { width: 100%; } }
 <div class="image"> <div class="img"> <div class="overlay"></div> </div> </div>

Add overflow: hidden to .img and forwards to slide animation.添加overflow: hidden.imgforwards到幻灯片 animation。

 html, body { height: 100vh; } body { margin: 0; width: 100%; }.image { animation: change 0.5s ease-out; height: 70vw; }.img { background-image: url("https://www.abroprojectafbouw.nl/wp-content/uploads/moddit-fly-images/468/foto-15-scaled-770x500-c.jpg"); background-size: cover; position: relative; width: 100%; height: 70vw; overflow: hidden; }.overlay { position: absolute; width: 100%; height: 70vw; background-color: #000; top: 0; right: 0; animation: slide 0.5s ease-out forwards; animation-delay: 0.6s; } @keyframes slide { 0% { left: 0; } 100% { left: 100%; } } @keyframes change { 0% { width: 0%; } 100% { width: 100%; } }
 <div class="image"> <div class="img"> <div class="overlay"></div> </div> </div>

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

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