Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

172
Views
How to repeat an image infinitely with scrolling back

I want to repeat an image on a website infinetly. The purpose of this website is only to show this image with an illusion of infinity. This means that my website should not have a start nor an end. It should scroll infinetly on the x and y axis. Or at least give the illusion of that. The image is precisely constructed so that if appending it n times, the transition is seamless.

So I've got a little experience with unity and have designed game levels, where the background repeats if the end of the image was reached.
My idea was to do the same with html, css and javascript. So this is what I've got so far:

HTML

<body>

<img src="weitsicht.png">
<img src="weitsicht.png">
<img src="weitsicht.png">


<script src="scripts.js" type="application/javascript"></script>
</body>

JavsScript

window.onscroll = function(ev) {
    // if reached bottom of page scroll back to the 1/3 to the top (second image) to give the illusion of infinity
    if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight) {
        window.scrollTo(window.scrollX, window.innerHeight / 3);
    }
    // if reached top of page, scroll down to next image to give illusion of infinity
    if ((window.scrollY) < 1) {
        window.scrollTo(window.scrollX, window.innerHeight);
    }
};

I haven't used css so far, but I'm open to use whatever it needs.

With my current work it doesn't appear to be infinitely, the scrolls aren't "smooth" and depending on the image size and screen size I have to resize the images manually.

Another solution I tried was this:

CSS

html {
    width: 100000px;
    height: 100000px;
    background: url('weitsicht.png') repeat;
    background-size: cover;
}

But this is neither dynamic, nor infinite.

How can I change my solution to create an illusion of infinty?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!