When using the CSS property position: absolute;, the scroll bar behaves erratically

To create a spinning tire effect as the background of my website, I need to implement very fast parallax scrolling. However, I encountered an issue where using position: absolute; on the background image caused the screen to jerk back up at the end of scrolling. Removing position: absolute; fixed the jerking but prevented the parallax scrolling from working properly. I am looking for suggestions on how to achieve fast background movement relative to the foreground without these issues.

I am currently using Bootstrap v4-alpha and the CDNs for jQuery and Popper from that version.

$(window).scroll(function() {
  var scrollTop = $(this).scrollTop();
  $('body').css('top', -(scrollTop * 4) + 'px');
});
body {
  background-image: url("/pexels-photo.jpg");
  /*background-repeat: repeat;*/
  position: absolute;
}

form#search {
  margin-top: 3%;
}

form#search>div.d-inline-block {
  width: 29%;
  margin: .5%;
}

form#search>div.d-inline-block#quantity {
  width: 5%;
  margin: .5%;
}

... (rest of the CSS code)
... (HTML code)

Live Demo

Answer №1

To enhance the scrolling experience, consider eliminating the position absolute attribute from the body tag.

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

Using CSS to center the text and adding a separator line in blank spaces for a clean and stylish look

Request to Create Centered Date Element with Line Borders I am looking to design an element where the date is positioned at the center, while two horizontal lines fill the empty space on either side. Ideal Design I Want to Achieve: My Current Approach a ...

The `innerHTML` function is responsible for closing HTML

My switch structure is set up as follows: switch (ratio) { case "16:9": imgContainer.innerHTML = '<img src="images/test-rata-de-aspect.jpg">' break case "4:3": imgContainer.innerHTML = '<img src="image ...

SolidJS createEffect will only trigger on changes after the initial rendering

When I was searching for a solution, I came across the need to only trigger a reaction after my component had been rendered for the first time. For instance: function InputName() { const [name, setName] = createSignal(""); const [nameError, ...

Create and start a new Google map after an AJAX update of a partial

I have successfully displayed a google map with markers, but I am facing an issue when trying to display the map within a partial that is refreshed using ajax. It seems like the final initialization line at the end of the code is not firing when using ajax ...

Load Vue dynamically to implement reCAPTCHA script

I am looking for a way to dynamically load a script like recaptcha specifically within the Register.Vue / login.Vue component. <script src="https://www.google.com/recaptcha/api.js?onload=vueRecaptchaApiLoaded&render=explicit" async defer> </s ...

Obtaining an array from an object with Meteor and MongoDB

I've been struggling for about a week trying to accomplish a simple task with MongoDB. Here is the document I'm working with: { _id: "mkikuQzrYdyQjL7Ry", links:[ 1: "link1" 2: "link2" 3: "link3" 4: "link4" ] } Is there a way to retrieve al ...

Yup's validation can be customized based on conditions

I have a scenario where an email field is displayed only when a checkbox is selected (boolean value is true). I want this field to be required only if the checkbox is checked (boolean is true) upon form submission. Here's what I have attempted so far ...

What is the correct way to extract results from an Array of Objects in Typescript after parsing a JSON string into a JSON object? I need help troubleshooting my code

Here is my code for extracting data from an array of objects after converting it from a JSON string to a JSON object. export class FourColumnResults { constructor(private column1: string, private column2: string, private column3: string, priv ...

Identifying the conclusion of a folder being dropped in vanilla JavaScript

I am working on determining when a directory tree has been completely traversed after being dropped onto a page. My goal is to identify the point at which the next process can begin once the entire folder and its sub-directories have been processed by the ...

Looking for a JavaScript regex pattern that matches strings starting with the letter "p" and containing at least

I have recently started learning about JavaScript regular expressions. I attempted the following expression for a string starting with the letter "p" followed by digits: p1749350502 The letter "p" is constant and the remaining digits are variable. Howeve ...

Utilizing jQuery or Javascript to obtain the title of the current webpage, find a specific string within it, and then apply a class to the corresponding element

Let's imagine I start with this: <title>Banana</title> and also have some navigation set up like this: <ul id="navigation"> <li> <a href=#">Banana</a> </li> </ul> Upon loading the sit ...

Error message: "Attempting to assign a value to the 'size' property of an undefined object, despite the fact that

I recently started delving into NodeJS development and have configured Visual Studio Code for JavaScript development in node applications. During a Pluralsight lecture on Objects, the instructor demonstrated creating two scripts, dice.js and program.js, a ...

Adding a scroll bar to a fixed container: tips and tricks

I am looking to implement a scrollbar in a fixed container for the cart products. The goal is to enable easy navigation through a large number of products added to the cart by scrolling within the container. Below is the HTML code snippet representing the ...

In order for Javascript to continue, it must first wait for a request to be completed

I have a beginner question that's been on my mind. I'm currently working on creating a wrapper for an API and I need to authenticate to receive the access token for further requests (please note, the API doesn't use OAuth). Here is a simpli ...

How can I modify hover to onclick in an Angular application?

I have implemented a CSS feature where an element flip flops on mouse hover, but I would like it to flip on click instead. How can I achieve this? <div class="card-flip-front"> <div class="panel panel-default"> <div class="w ...

Unforeseen Extra Information is being transmitted along with Socket.io and Jquery

Issue : There seems to be a problem with the chat message printing an extra character in msg. Upon console logging, an additional object value is appearing in the state. What could be causing this issue? Console log output : 2{"message":"e"} 1{"mess ...

Sending the servlet response back to the original JSP page

Is there a way to display the message "File uploaded successfully" on the upload.jsp page? The page retrieves session attributes, checks the user's department, and acknowledges users by displaying the name of their department. When users upload files ...

Convert grouped data in Javascript into a JSON array

After implementing the code snippet provided below, I successfully managed to group objects from my existing dataset using Underscore JS. The grouped data is displayed in distinct groups as depicted by the output: {Group1: Array[10], Group2: Array[13], G ...

Guide on saving the token in local storage or cookies to grant access to specific web pages for users

Currently, I am in the process of developing an authentication system using Node.js, MySQL, and Express. Initially, I focused on saving and verifying user credentials in the database. Recently, I incorporated JWT (JSON Web Token) into the system. My next s ...

Creating geometric designs on an image and storing them using PHP

I am attempting to retrieve an image from a specific location on my server, draw lines on it, and then save the modified image back to the same location. Below is the code I am using: function drawShapes($src_path, $json) { echo "---inside dra ...