The HTML document is wider than the screen

Encountering a strange issue where the <body> tag is wider than my monitor, even though it shouldn't be. I have implemented some JavaScript to create a parallax effect by adjusting the background based on scroll offset. However, when the background is set to 100% width, it abruptly snaps and stretches out. This can be observed by zooming out of the page, causing the background to appear larger.

Visit the website here

Can anyone identify what might be going wrong with this setup? The provided JavaScript code is below, and feel free to inspect the CSS for additional details. Additionally, there seems to be a noticeable slowdown in performance compared to when everything was running smoothly.

var ismobile = /Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
if (!ismobile){
    window.onresize = function(event) {
        //Detect window size and adjust padding accordingly
        if (window.innerWidth > 835) {
            var newPadding = parseInt(window.innerHeight)/2.8;
            newPadding = newPadding.toFixed(0);
            var limitPadding = 221;

            //Apply new padding value to header
            if (newPadding > limitPadding) {
                doc("header").style.padding = newPadding + "px 0px";
            }
        }
    };
    window.onscroll = function() {
        var speed = 0.7;
        var newPos = "100% " + (window.pageYOffset * speed) + "px";
        document.body.style.backgroundPosition = newPos;
    };
}

Answer №1

To prevent overflow on your website, simply add the overflow property to your body element...

body {overflow: hidden;}

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

Utilizing HighCharts in Your Project

View the graph here $(function () { var chart; $(document).ready(function() { chart = new Highcharts.Chart({ chart: { renderTo: 'container', type: 'column', margin: [ 50, 50, 100, 80] ...

Mass delete MongoDB documents using NodeJS

I'm dealing with a collection containing some messy data that I need to bulk delete based on a certain criteria. While it's a simple task in the mongo shell using db.collection.remove() with the justOne option, I'm wondering if there's ...

Activate drag-enter on a parent element, excluding its child elements

Here is the code snippet I am working with: a div container with a header and body covering 100% of its surface: <div class="ui-layout--col"> <div class="ui-layout--cell-container"> <!-- $0 --> <div class=&quo ...

What is the reason that applying bg-dark on a Bootstrap navbar prevents the background-color from being applied?

Is it possible to change the background-color of a Bootstrap navbar by adding custom CSS? I have my own CSS file loaded after Bootstrap, so I assumed my styles would take precedence. However, when I try to apply a new background color to the navbar, it doe ...

The behavior of JavaScript execution when typing in a text field does not align with the expected sendKeys method

Whenever I run my tests on a Linux machine, I encounter an issue with the way text is typed using the following code snippet: visibleElement.clear(); visibleElement.sendKeys("I am running on linux machine"); Instead of typing the text correctly as expect ...

After successfully creating an account, the displayName consistently appears as null

I have a Vue project that utilizes Firebase as the backend. User registration is done using email and password. Below is the method used in Firebase: firebase.auth() .createUserWithEmailAndPassword(this.user.email, this.user.password) . ...

AWS Lambda applies quotes to create the event input

I'm encountering a problem with my Python 3.8 AWS Lambda function that is meant to handle form inputs from a web application. The data from the form inputs gets passed to the Lambda function and ends up in the event dictionary. However, lambda seems t ...

The attempt to retrieve property descriptors of Node.prototype using Object.getOwnPropertyDescriptors()

As I keep track of errors on a webpage that utilizes JavaScript, an issue arises when running the following code: JSON.stringify( Object.getOwnPropertyDescriptors(Node.prototype) ); An error is thrown stating: undefined is not a function I sus ...

Leveraging npm packages in Meteor's Angular 1.3 framework

Although it may sound like a silly question, I am still confused. It has been said that Meteor has native support for npm modules in version 1.3. I am currently using Meteor with Angular integration. From the tutorial, it appears that using npm modules sh ...

What is the best strategy for managing various contexts in React?

Just diving into React - I've been experimenting with using multiple contexts in my App component. Following the instructions laid out in the official guide on working with multiple contexts. Let me share my current code: App.js import React from " ...

Monitoring the health and availability of AWS S3 buckets via API for checking their status

While working on a node.js application, I successfully implemented s3 file upload. However, there have been instances when the s3 bucket goes down for maintenance or other reasons. To address this issue and keep users informed, I wanted to incorporate an A ...

What is the process for reinserting a list item into the nested elements?

Looking for help with manipulating a menu in HTML? I have a menu that I want to modify by removing and adding list items. While I've had success removing items, I'm struggling to properly use the add method. Here's an example of what my menu ...

Center your logo and position the text to the left in your Bootstrap 5

I am struggling to align my navigation bar with the toggler button on the left and the brand logo in the center, similar to the image provided below: https://i.sstatic.net/k34m9.png I am having difficulty achieving this layout. Currently, my code display ...

Troubleshooting a deletion request in Angular Http that is returning undefined within the MEAN stack

I need to remove the refresh token from the server when the user logs out. auth.service.ts deleteToken(refreshToken:any){ return this.http.delete(`${environment.baseUrl}/logout`, refreshToken).toPromise() } header.component.ts refreshToken = localS ...

Can one recover a Javascript file from a server?

In Python, I am able to extract Javascript code from an HTML file using the code snippet below. import urllib2, jsbeautifier from bs4 import BeautifulSoup f = urllib2.urlopen("http://www.google.com.ph/") soup = BeautifulSoup(f, "lxml") script_raw = str( ...

Utilize Discord.js to send a message and patiently await your response

I am facing an issue while trying to code a Discord bot. I'm struggling to make it wait until the user inputs 'Y' or 'N'. Specifically, I am currently working on the ban command and everything seems to be functioning well until the ...

Displaying an IP camera feed on a three.js canvas

I've been presented with a seemingly straightforward task in JavaScript that I'm not very familiar with. The challenge is to take an IP camera stream and display it on a three.js canvas. To start, I came across an example that uses a webcam inst ...

Develop server-sent events feature within Firebase functions

I have been attempting to integrate server-sent events functionality into a firebase function, where it continuously sends data back to the client side while the function is running, rather than waiting until the function completes. Despite my efforts, I h ...

Breaking down a JavaScript string into two separate arrays

Imagine you have a string formatted like this: "Applejack=A.J.+Applecar,Lemon+Vodka=AlfieCocktail+ Sunset + SexOnTheBeach" Your task is to write Javascript code using .split() to parse long strings (up to 100000 characters) and separate them int ...

Adjusting variables in Bootstrap using the app.scss file is a helpful customization technique for

As I work on a template that will be utilized by various individuals across different projects, ensuring it functions seamlessly without the need for project-specific modifications is paramount. In this particular case, my goal is to modify the $spacer va ...