Smooth Infinite Scrolling Banner [CSS Only]

后端 未结 1 1939
梦谈多话
梦谈多话 2021-01-13 11:09

Looking to optimize this infinite scrolling effect, however I\'m not entirely sure how to create a smooth transition when looping back to the original image. At 10s it\'s ha

相关标签:
1条回答
  • 2021-01-13 11:45

    Check this out: https://jsfiddle.net/sergdenisov/wb28eeh2/3/.

    You had unnecessary space between images (cause display: inline, read this article — https://css-tricks.com/fighting-the-space-between-inline-block-elements/). I set:

    .photobanner, .photobanner2 {
        font-size: 0
    }
    

    Then I remove padding-right: 2px and set:

    .photobanner img, .photobanner2 img {
        margin-right: 5px;
    }
    

    Really space between 2 img tags was 6px, now it's 5px.

    Now we can calculate required margin-left for animation: 6 x (350 + 5) = 2130px. That's it.

    0 讨论(0)
提交回复
热议问题