简体   繁体   English

css animation 重复剪切图像

[英]css animation repeat cuts the image

I would like to create some css animation on the home page of my site, with some notes falling.我想在我的网站主页上创建一些 css animation ,一些注释掉了。 Here is the example: http://labandallonnaise.org/joomla/ (link no longer demonstrates behavior) We can see that the notes are falling, then we have nothing before the next sequence.这是示例: http://labandallonnaise.org/joomla/ (链接不再演示行为)我们可以看到音符正在下降,那么在下一个序列之前我们什么都没有。

Here is the code这是代码

.notes-wrapper {
    overflow: hidden;    
    height: 630px;
    top: 0px;
    right: 0px;
    bottom: 0px;
    left: 0px;
    margin-top: -75px;
    margin-bottom: -75px;
    margin-left: -500px;
    margin-right: -500px;
}

.notes {
    background: url("gantry-theme://custom/images/background.svg") center !important;
    height: 6300px;
    animation: fall 10s linear infinite;
    overflow: hidden;
    z-index: 0;
    background-repeat: repeat;
    background-size: cover;
    top: 0px;
}

.notes img {
    animation: none;
    background: transparent;
}

@keyframes fall {
    0% {
        transform: translateY(-1050px);
    }   
}

<div class="notes-wrapper"> 
  <img style="display: block; margin-left: auto; margin-right: auto; animation: none; background: transparent;" src="images/logo/BandAllonnaisedudule.png" alt="" />
  <div class="notes"> </div>
</div>

how can I have continuous animation?我怎样才能有连续的 animation?

It depends on exactly what effect you want with various viewport aspect ratios.这取决于您想要使用各种视口纵横比获得的效果。

Whatever the details, you need two copies of the SVG so that you don't get a gap when one has reached the bottom and starts again.无论细节如何,您都需要两份 SVG 副本,这样当一个到达底部并重新开始时,您就不会出现间隙。

Here's one way to get continuity which puts before and after pseudo elements on the notes div both of which animate down the full height of the viewport.这是一种获得连续性的方法,它将伪元素之前和之后放置在注释 div 上,这两者都在视口的整个高度上进行动画处理。 One starts in the viewport, the other above it.一个从视口开始,另一个在视口上方。

This is a simplistic way of doing it as it doesn't require you to know anything about the aspect ratio of the background image.这是一种简单的方法,因为它不需要您了解有关背景图像纵横比的任何信息。 It would be possible to get better control and produce different results depending on what you'd like to happen on narrow or wide devices.根据您希望在窄或宽设备上发生的情况,可以获得更好的控制并产生不同的结果。 For example, should the notes always fit in completely horizontally, however small they then go?例如,音符是否应该始终完全水平放置,无论它们有多小 go? Should there always be only one copy of the background however wide the device and so on.无论设备有多宽,是否总是只有一份背景副本,依此类推。

 .notes-wrapper { overflow: hidden; position: relative; top: 0px; right: 0px; bottom: 0px; left: 0px; width: 100vw; height: 100vh; }.notes { position: absolute; top: 0; left: 0; width: 100vw; height: 100vh; }.notes::before, .notes::after { content: ''; background-image: url("https://ahweb.org.uk/background.svg"); position: absolute; height: 100%; width: 100%; animation: fall 10s linear infinite; overflow: hidden; z-index: -1; background-repeat: repeat no-repeat; background-size: auto 100%; background-position: center; }.notes::before { top: -100%; }.notes::after { top: 0; } @keyframes fall { 100% { transform: translateY(100vh); } }
 <div class="notes-wrapper"> <img style="display: block; margin-left: auto; margin-right: auto; animation: none; background: transparent;" src="images/logo/BandAllonnaisedudule.png" alt="" /> <div class="notes"></div> </div>

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

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