Tips for creating endless scrolling <div> functionality

I have been attempting to create a scrolling effect in this div with columns that moves down infinitely - Example, like the one on this Google developer page - Google developers || Infinite scroller image. However, I have not been successful so far. I have a <div> called "imgs" containing a certain number of images. When "imgs" reaches a certain position, the images from the bottom of the div are moved to the top invisibly for the user. Here is some of my code:

let imgsContainer = document.getElementById("imgs");
let imgAppear = document.getElementById("imgAppear");

function imgsContainerMove() {
         let top = 0;
         setInterval(imgsContainerMoving, 25);

         function imgsContainerMoving() { // Animation
                   top++;
                   imgsContainer.style.top = top + '%';
                   if (top === 100) top = 0; //Top reset

                   if (imgsContainer.style.top == "1%") {
                    Array.from(document.querySelectorAll("div.imgs > img")).slice(-6).forEach((image) => imgAppear.prepend(image)) //Adding images to the top
                }

            }
        }
        imgsContainerMove(); // execute function
body{
margin: 0;
}
.gallery-block {
    display: flex;
    flex-flow: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    background-color: #2B3C35;
}

.gallery-bg {
    position: relative;
    margin: 50px 0;
    padding: 0 10px;
    width: 100%;
    height: 40vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
}

.gallery-bg .overlay {
    position: absolute;
    top: 0;
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: auto;
    background: rgb(43, 60, 53);
    background: -moz-linear-gradient(0deg, rgba(43, 60, 53, 1) 0%, rgba(1, 2, 2, 0) 50%, rgba(43, 60, 53, 1) 100%);
    background: -webkit-linear-gradient(0deg, rgba(43, 60, 53, 1) 0%, rgba(1, 2, 2, 0) 50%, rgba(43, 60, 53, 1) 100%);
    background: linear-gradient(0deg, rgba(43, 60, 53, 1) 0%, rgba(1, 2, 2, 0) 50%, rgba(43, 60, 53, 1) 100%);
}

.imgs {
    position: absolute;
    width: 75vw;
    columns: 200px;
    column-gap: 15px;
}

.imgs img {
    width: 100%;
    margin-bottom: 15px;
    border-radius: 5px;
}
<div class="gallery-block">
  <h2>Gallery</h2>
  <img src="img/triangle.png" alt="" class="triang">
  <div class="gallery-bg">
      <div class="imgs" id="imgs">
          <!-- Insert your images here -->
        </div>
    <div class="overlay"></div>
</div>

Answer №1

To solve the issue, change the CSS property from overflow:hidden to overflow:auto

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Creating a unique checkbox design using pure CSS and HTML

I'm looking to design a customized checkbox using just HTML and CSS. Here's what I have so far: HTML/CSS: .checkbox-custom { opacity: 0; position: absolute; } .checkbox-custom, .checkbox-custom-label { display: inline-block; vertica ...

Always keep this checkbox checked and only uncheck the others when necessary

Whenever I check a checkbox and then click on another checkbox, I don't want the initially checked checkbox to be unchecked, but rather a different one... For example: If I check checkbox 1, only checkbox 1 is checked; If I check checkbox 2, both ...

I am looking to host two Nuxt.js (Vue.js) applications on a single server using PM2

To begin using Nuxt.js, follow these steps: vue init nuxt/express myapp1 vue init nuxt/express myapp2 The structure of my projects is as shown below. /workspace/myapp1 (Nuxt.js application) /workspace/myapp2 (Nuxt.js application) Within my workspace, ...

JavaScript's regular expression does not fully match until the end of the given string

In my JavaScript code, I am validating dates using a regular expression. The specific regular expression I am utilizing is as follows: /^(((((0?[1-9])|(1\d)|(2[0-8]))\/((0?[1-9])|(1[0-2])))|((31\/((0?[13578])|(1[02])))|((29|30)\/((0?[1 ...

Styling with CSS to ensure divs are displayed in two rows

Check out this example I found: https://jsfiddle.net/n3qs0wke/ .wrapper { max-width: 600px; border: 1px solid #333; } .big-div { min-width: 212px; min-height: 212px; max-width: 212px; max-height: 212px; display: inline-flex; ...

Is it possible to use Bootstrap without using rows?

I am a fan of using bootstrap, but I am currently facing a challenge that requires a grid layout where cells stack vertically without any visible lines separating them. Similar to the layout seen on Pinterest. While Bootstrap's normal grid system wor ...

Having trouble sending data from the controller to the view in Laravel 8

I am struggling to display data retrieved from the database in my view through the controller. Despite trying various solutions found on similar questions, none of them seem to be effective. My main goal is to showcase a list of employees on my admin page. ...

What is the correct way to import the THREE.js library into your project?

I recently added the three library to my project via npm. Within the node_modules directory, there is a folder named three. However, when I tried to import it using: import * as THREE from 'three'; I encountered the following error: ReferenceEr ...

Show the saved email message text on an HTML webpage

Is there a way to show the email content stored in a HTML page? $.ajax({ type: "POST", url: "./mailBody.php", dataType: 'json', success: function (data) { $.each(data, function(index, element) { $('.mail ...

Switching elements in an array using Vue.js

Within my vue.js web application, I am attempting to switch the positions of two rows in a forum. Below is the code snippet I am using: export default { data() { return { forums: [] } }, met ...

Conceal a Div Element on a Website

My website's home page features a CSS animation that slides two images with a high z-index off the screen to reveal the content below. I want this animation to only run the first time the page is accessed during a session, and not every time the user ...

Is lazy initialization for useState accompanied by any disadvantages?

The documentation for useState explains: If the initial state is the result of an expensive computation, you may provide a function instead, which will be executed only on the initial render While I see the reasoning behind using a function for an expe ...

Timeout error of 10000ms occurred while using await with Promise.all in Mocha unit tests

Document: index.ts // Default Exported Classes getItemsA() { return Promise.resolve({ // Simulating API call. Mocking for now. success: true, result: [{ itemA: [] }] }); } getItemsB() { return Promise.resolve({ // Simulating API cal ...

What steps are necessary to alter the background color of a jumbotron?

Can someone help me figure out how to change the background-color of the 'jumbotron' class in Bootstrap? The default color set in bootstrap.css is #eee. I've tried various methods like replacing it with none, none !important, or transparent ...

The DataTable fails to refresh following modifications to the HTML table

After making changes to a table row using basic JavaScript, the datatable is not updating properly. Despite seeing the updated values in the table view, retrieving data from the datatable shows the old values. Below is the structure of my table: <tab ...

Creating a vertical animated drop-down menu is a great way to add some flair to

I've been attempting to create a dropdown menu on my website similar to the one found at https://www.geeksforgeeks.org/python-programming-language/ Here's what I'm aiming for: https://i.sstatic.net/T5iWw.png I can't figure out why my ...

What is the significance of h being undefined?

I have successfully set up a new Vue project using vue create and added Storybook with no issues. However, after installing storybook-addon-designs and following the instructions in the readme to add it to my story, I encountered an error in my console sa ...

"Bringing back the page zoom/scale with the click of a button

I've hit a roadblock as I search for code to tackle my issue. Despite scouring Google and Stackoverflow extensively, I haven't come across anything that addresses my specific problem. Essentially, I have a button on my webpage labeled "Restore s ...

When the window is resized, the text and images become jumbled and distorted

As a beginner in CSS, I am encountering an issue where the text and images on my website get distorted when I resize the window. How can I resolve this? HTML <img src="images\titles_03.jpg" class="tt1" > <img src="images\titles_05.jpg ...

Oops! The page you're looking for at /api/tasks

Whenever I try to access: http://localhost:3000/api/tasks, I keep getting a "Cannot GET /api/tasks" error message. This is my server.js: var express = require('express'); var path = require('path'); var bodyParser = require('body ...