Design a JavaScript Image Showcase with Background Images

Struggling to create a full-page gallery that allows for vertical scrolling through one image at a time. I've attempted different options but can't seem to crack it.

Here is a snippet of my code:

<style>

#img1 {
background-image: url("<?php echo $image ;?>");
height:100vh !Important;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}

#img2 {
background-image: url("<?php echo $image2 ;?>");
height:100vh !Important;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}

#img3 {
background-image: url("<?php echo $image3 ;?>");
height:100vh !Important;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
</style>

<div id="img1"></div>
<div id="img2"></div>
<div id="img2"></div>

I'm in need of a javascript/jquery solution to detect when the user has scrolled, with the intention of changing images if they scroll up or down by 10 pixels.

For reference, here's the kind of layout I'm aiming for:

Answer №1

If you're looking to create a seamless scrolling experience for your webpage or gallery, consider using JavaScript libraries like "fullPage.js, smart scroll, pagePiling.js". These tools can help you achieve the perfect scrolling effect you desire. For more information, check out the following resources:

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

How to automatically embed a p5.js canvas into an HTML canvas with the drawImage() method

Whenever I attempt to draw the p5.js canvas into an HTML canvas using drawImage(), I always encounter this error: Uncaught TypeError: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The provided value is not of type ' ...

Clearing selections from a multiple-choice input field

I am seeking to implement a delete feature in a multi-select element similar to the functionality seen here on stackoverflow when selecting multiple tags for a question. Once an item is selected, I would like to display a close icon next to it so that user ...

Utilizing Wordpress post images to dynamically change background URLs in CSS

Is there a way to dynamically set a background image in CSS using PHP, specifically the Wordpress post image? background: <?php if(has_post_thumbnail()){ $img = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'dest ...

Refrain from repeatedly iterating through the URLs that have already been visited as generated by

I have a database in MongoDB where each document has a unique URL for access. The objective is to show the user a random document URL that they haven't visited yet, until all documents have been viewed. Once all documents have been seen, the collecti ...

implement a jQuery loop to dynamically apply css styles

Attempting to utilize a jQuery loop to set a variable that will vary in each iteration through the loop. The plan is for this variable to be assigned to a css property. However, the issue arises where every css property containing the variable ends up with ...

What is the best way to ensure a jQuery UI slider recognizes when the mouse is released after being clicked?

I have integrated the jQuery slider into my application and am facing an issue with triggering an event to update the database upon releasing the slider. Currently, I am using the following code snippet: $('.ui-slider-handle').mouseup(function () ...

Is .closest combined with :contains finding too many elements for my taste?

My goal is to highlight specific rows in a table that have a particular class assigned on $(document).ready. I attempted to use .closest with a tr to target individual rows, but instead it selects all rows and I'm unsure why. I've experimented w ...

Scale the cylinder in Three.js from a specific point

Can a cylinder be resized along the Y-axis starting from a particular point? Instead of the cylinder expanding from its center in both directions to the new scale, is it possible for it to grow upwards/downwards only like a bar chart? Current code : fu ...

Executing the .on click event before the dynamic class is tapped in jQuery

My code includes a class (.elink) that changes to another class (.playing) when clicked. However, when .playing is clicked, it should change again to .pause. The issue I am facing is that when I click .elink, it adds both .playing and .pause simultaneously ...

Retrieving response body in success and error using AJAX

Forgive me for asking a somewhat silly question, but I really need your assistance. I am trying to gather information on how to handle responses within an AJAX call. $.ajax({ type: "POST", url: '/register', data : r ...

What is the best way to package JS in a partial view from ASP.NET MVC4 when it is sent back through AJAX?

Currently utilizing the System.Web.Optimization framework for bundling and minifying JavaScript, along with @section Script{ } sections to organize all scripts at the bottom of the page. This includes jQuery resources. In one of my pages, there's an ...

Mastering the art of utilizing callbacks in AngularJS for consuming an API

Having trouble handling data from an API and structuring it effectively before passing it to the controller. I've created a factory that retrieves user data from the API, but the provideAllUserData function is causing issues. Below is my services.js: ...

React native and redux: Updating state with setState is not possible during an ongoing state transition

Currently in the process of developing an app utilizing React Native and redux, alongside Express js for handling Ajax requests. Encountering an issue where the data from my Ajax request fails to load, accompanied by the following warning: Warning: set ...

Accessing a child element within a div with the help of the keyword "this" in jQuery

I am encountering an issue with accessing and updating attributes of iframe elements within HTML containers on a page. When I attempt to loop through each "iframeHolder" and target the iframe element within it, I encounter errors. Below the HTML code snip ...

A guide to mastering Controllers in AngularJS

Trying to set up a basic page with a controller but encountering difficulties. The HTML code is straightforward, with an Angular script included, but the functionality isn't working as expected. The HTML snippet: <!DOCTYPE html> <html ng-ap ...

Troubleshooting problem with input and textarea losing focus in Ajax requests

Experiencing an issue with submitting information using ajax. For instance, there are 20 rows. When a row is clicked, it displays all details about services. $('tr').click(function() { var servicesUpdateId = $(this).attr('data&a ...

``Advanced Web Development: Dealing with HTML5, CSS3, and

I am facing an issue while implementing a design from the CSS and HTML login form templates on my project. Below is the snippet of my HTML: <p id="firstname_line"> <label>First Name:</label> <input type="text" name="firstnam ...

Questions regarding prototype-based programming in Javascript

I am interested in achieving the following using Javascript: function A(){ this.B = function() { ... }; this.C = function() { <<I need to call B() here>> } ; }; I came across a method of method overloading, but I am curious to know ...

Change the size of the image to use as a background

I have an image that is 2000x2000 pixels in size. I originally believed that more pixels equated to better quality with less loss. Now, I am looking to display it on my browser at a resolution of 500x500. To achieve this, I attempted to set the image as t ...

Is there an issue with the second bootstrap navbar overlapping a dropdown-menu from the first navbar?

My issue involves two fixed-top navbars, where the dropdown-menu from the first one is being overlapped by the second navbar. I've tried adjusting z-index, positioning, and overflow properties without success. I have also looked at similar questions b ...