Strange glitch at the top of pictures?

After spending the past few days working on a website, I just uploaded it and noticed some strange lines appearing at the top of images when scrolling. Any suggestions on how to fix this issue?

You can view the website here.

The images on the site are moving at different speeds using JQuery. Here is an example of the HTML for one of the images:

<div class="mountains1"></div>

Here is the CSS:

.mountains1 {
  background: url(../img/mountains1.png) repeat;
  background-size: cover;
  width: 100%;
  height: 800px;
  position: absolute;
  z-index: 13;
}

And here is the JavaScript:

var parallax = function(){
  var $scrollY = $(window).scrollTop();
  var $scrollX = $(window).scrollLeft();
  $('.mountains1'  ).css('top', '1640' -($scrollY * 1) + 'px');
}

$(document).ready(function(){parallax();});
$(window).scroll(function(){parallax();});

I am encountering this issue in Safari but not in Chrome. When I try using the `ceil()` or `round()` methods, it seems to break things.

These are the adjustments I made based on Leo's feedback:

var parallax = function(){
var $scrollY = $(window).scrollTop();
var $scrollX = $(window).scrollLeft();
var $scrollYint = Math.round($scrollY);
$('.cloudback'  ).css('top', '-375' -($scrollYint * 0.4) + 'px');

// More changes made for other elements

}

Answer №1

After reviewing your code, it seems that you are utilizing JavaScript to determine the top value for your absolutely positioned images. The issue arises when the top value yields a result with a decimal point, causing the line to appear above the images. For instance, top: 1642.4px; instead of top: 1643px.

To rectify this, make sure to adjust your parallax function to round the top value for your images in order to prevent any decimal results.

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

The functionality of the jQuery addClass method is failing to work when implemented on

Hello, I'm currently attempting to implement a CSS Style on an <img> tag that does not have any assigned class or id. Below is my code snippet: ===CSS=== .tgll-navi { //custom class for navigation bar .navi-left { //.navi-left float:right; ...

Angular: When a user clicks, the text from the input fields is added to an array

Initially, I am a bit perplexed as I begin working on this task. I have a straightforward table where the data is fetched from a database and inserted into the DOM using Angular. The table comprises an option and its corresponding value. My goal is to all ...

Manipulating anchor links with jQuery by adding and removing classes

I am struggling to understand why I cannot remove a class from an element and then add a new one. Changing the CSS using .css(...) works, but for some reason .removeClass and .addClass are not functioning. Interestingly, I am able to successfully add and ...

Passing parameters to a controller method in AngularJS from a directive

Embarking on my Angular JS journey, I have begun creating custom directives for a project. As part of the task, I needed to generate an angular tree and found a code snippet on a plunkr sample by someone else. Although it is not originally my code, I tried ...

Conflict in the naming and scoping of IE7 and IE8

While reviewing some code, I encountered a problem in Internet Explorer 7 and 8. Despite the constructor executing properly when stepped through, upon returning I received an error stating "Object does not support this property or method." How frustrating! ...

Modify a specific field in a row of the table and save the updated value in a MySQL database

I have successfully retrieved data from a database and displayed it in a table. Now, my goal is to enable editing of a specific field within a row and save the updated value back into MySQL. Here is the code snippet that includes displaying the data in th ...

Guide on parsing JSON data received from the frontend

Here is the HTML code that I am working with: <div id="loginform"> <form class="loginIn" name="loginform"> <input type="text" name="login"> <input type="password" name="password"> <input type="submit" value="Войт ...

What is the most efficient way to transfer substantial data from a route to a view in Node.js when using the render method

Currently, I have a routing system set up in my application. Whenever a user navigates to site.com/page, the route triggers a call to an SQL database to retrieve data which is then parsed and returned as JSON. The retrieved data is then passed to the view ...

A guide on how to mention users in Discord.js

I attempted to get the bot to mention a member using @, but when I used message.channel.send(<@id>+"text") it showed an error message saying unexpected sign '<'. Is there a way to successfully mention members with the bot? ...

JavaScript: Comparing an array of arrays with multiple identical elements to another array and returning a unique array of arrays

const array1 = [[1, 2, 3], [1,3,4], [1,2,5]]; let b = [] let c = [2,3] array1.forEach(e => { c.some(r => { if(e.includes(r)) b.push(e) }) }) console.log(b) Upon running the code, the output was [ [ 1, 2, 3 ], [ 1, 2, 3 ], [ 1, 3, ...

What are the steps to lift non-React statics using TypeScript and styled-components?

In my code, I have defined three static properties (Header, Body, and Footer) for a Dialog component. However, when I wrap the Dialog component in styled-components, TypeScript throws an error. The error message states: Property 'Header' does no ...

Sharing and showcasing files directly from a local directory

Recently diving into NodeJS and web development, I've successfully used multer to upload a single file within my web application. The file gets uploaded to my "uploads" folder flawlessly, and now I'm planning on storing the file path in my databa ...

Problem encountered when utilizing map() function - it returns undefined

const items = [ { item: "apple", cost: 2 }, { item: "orange", cost: 4 }, { item: "carrot", cost: "" }, { item: "grapes", cost: 5 }, { item: "milk", cost: 3 }, { item: "bread" ...

Error encountered in NodeJS: Promise TypeError - res.json is not a function while handling pre-signed URLs. This results in

I'm having trouble generating a list of pre-signed URLs for files in my private S3 bucket. Despite researching similar issues on multiple forums, I can't seem to resolve the error with the res.json function in my code. Can someone please help me ...

What is the process for linking pallet items to mxgraph charts?

Hello, I am a beginner with mxGraph and currently working with Angular 4. My project involves having the palette in one component and the diagram in another. However, I am facing an issue where the objects from the palette are not dropping into the canva ...

Error: obj is not a valid operand for the 'in' function when attempting to retrieve data with JQuery JSON

Check out this code snippet jQuery('select[name="' + element + '"]').html('<option value="">Select</option>'); jQuery.each(data, function(key, value) { jQuery('selec ...

Error 500 on Firebase: Issue solving "firebase" in "firebase.js" not resolved

Struggling to incorporate Firebase into my latest React project, I keep encountering the dreaded "The development server returned response error code: 500." Despite creating a firebase.js file to house my Firebase configuration details, I am at a loss as ...

Incorporate Add to Homescreen functionality into your Angular 4 Project using JavaScript

Currently I am in the beginning stages of learning Angular development. One of my assignments involves integrating the add to homescreen jQuery plugin into one of my pages. This is my attempt at implementing it in my home.component.ts file: ngAfterViewIn ...

What are some methods for transferring the state variable's value from one component to another in React?

I have the following scenario in my code: there is a Form.js component that interacts with an API, stores the response in the walletAssets state variable, and now I want to create a separate Display.js component to present this data. How can I pass the v ...

The Chrome extension I created using JQuery to trigger 'keyup' events is not updating the value of the 'input' field on a website that utilizes knockout JS

I am currently working on developing a Google Chrome extension for a website that appears to be utilizing 'knockout JS'. Let's take a look at the HTML element below: <input type="text" class="form-control text-right" id="amount" autoco ...