As I scroll past the top or bottom of the page, the body's background color transitions to a new shade

I am encountering an issue with my next.js app where the body background color is set to black. Here is the code in globals.css:

body {
  background-color: black;
  padding: 0;
  margin: 0;
  font-family: 'Titillium Web', sans-serif;
}

However, when I scroll down past the bottom of the page in the browser, this is what happens:

The background turns purple (which is the background-color of my "Layout.tsx" inside the body).

In Chrome Developer Tools, this is how the body is displayed:

And here is the layout-main loaded from "Layout.tsx" shown in Chrome Developer Tools:

How can I make sure that the black body background extends throughout the entire background, even when I scroll down past the bottom?

Answer №1

Personally, I find success by assigning a background-color to the html element that matches the color value of the body element. In this scenario, it would look like this:

html { background-color: black; }

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

Crafting a dynamic inline search form with Bootstrap

My goal is to replicate the design in this image: This is my current progress: ...

Discovering the initial word of a string using jQuery

I'm currently facing an issue with jQuery that I need help solving. Here's the scenario: I am creating tooltips and positioning them directly under a specific trigger using CSS. Everything is functioning correctly, but there is one problem: In ...

What is the best way to assign a single class from an array to every list item in a particular sequence?

html <ul class="logoUl"> <li class="orange"></li> <li class="blue"></li> <li class="green"></li> <li class="pink"></li> </ul> SCRIPT if (selectedCategory == 'currentAll&apo ...

What might be causing the in-viewport javascript to not work in my code?

Why is my in-viewport JavaScript code not functioning properly? Link to JSFiddle code When the Click to move button is clicked, the cat image will slide correctly. However, when implementing the following code: if($("#testtest").is(":in-viewport")) ...

Determining the best use-case for a React framework like Next or Gatsby versus opting for Create React App

As I delve into the world of React and JavaScript, I find myself in the fast-paced prototyping stage. I can't help but ponder at what point developers choose to utilize frameworks like Next.js or Gatsby.js over the usual Create React App. I'm pa ...

The parent container is not properly wrapping its content in Internet Explorer only

Check out this code snippet I have here: https://jsfiddle.net/kimwild/mtxgtwr5/2/ main#wrapper { z-index: 1; width: 100%; position: relative; overflow: hidden; background-color: red !important; border: 10px dotted #4D37DB; } figure#about-im ...

Struggling with implementing a materialize modal?

I am encountering a problem with Materialize. This time, I am trying to create a modal div, but it doesn't seem to be working. The button is created, but when I click on it, nothing happens. I have made sure to link all the necessary Materialize files ...

We regret to inform you that the Serverless Function in NextJs has surpassed the maximum size limit of 50mb

Recently, I've started working with NextJs and encountered an issue while attempting to deploy my project on Vercel. The error message that popped up looked like this: Error! The Serverless Function "api/auth" exceeds the maximum size limit of 50mb, ...

Transfer the local environment variable from .env.local to the Vercel project

Is there a way to efficiently transfer all environment variables from the .env.local file to a Vercel project? Must I painstakingly add each one individually using the command vercel env add [name] [environment] [gitbranch] < [file] as outlined in the ...

Invisible boundary line within the column

My task involves creating a table using div elements. The layout of the table includes two columns structured as follows: <div> <div class = "columnborder"><span>Some text for column 1</span></div> <div><span>Some ...

What is the best way to stop a jQuery function from applying titles extracted from the first row th's in thead's to multiple tables in a document?

My circumstances: I am new to jQuery and Stack Overflow, seeking assistance for my website project. The challenge: Building a website using Bootstrap 3.3.6 with intricate data tables that need to be stacked dynamically on mobile devices using CSS. It is c ...

The length of Array(n) is incorrect when running on production in Next.js

My goal is to create an array of a specific length in TypeScript, but I am encountering an issue where the array length is incorrect when running my app in production mode (minified version). For example, when I execute console.log(Array(3)); in developme ...

Tips for maintaining consistent webpage layout across various screen sizes

Although this method may seem outdated, I have always been intrigued by how it was accomplished. In the past, before websites became responsive, pages would simply shrink down to fit on mobile devices without adjusting their appearance. How was this achie ...

Is there a way to align the image to the left within the div contained in my header section?

I am facing an issue with positioning the logo in the header section of my website. It appears correctly on the left side for tablet and mobile versions, but on desktop, it does not align to the corner as desired. I tried adding a right margin, but I belie ...

Hydration Error arises when Next.js SSG Suspense is triggered

My static site is encountering an issue when trying to display a simple list of items retrieved from Supabase. Everything was working fine in React 17, but after upgrading to React 18, I am now getting sporadic errors and the fallback doesn't consiste ...

Identifying redirection occurrences in React: A comprehensive guide

After adding a redirect and sending a data query parameter, it seems that the useEffect hook is not being triggered as expected. Why is this happening? I've tried the following: useEffect(() => { console.log('LRAL useff get called ...

Attempting to display divs at the bottom when hovering over menu options

I need help troubleshooting my HTML and CSS code. I want to be able to hover over a menu item and have the corresponding div appear at the bottom. Can you point out what's wrong with my code? <!DOCTYPE html> <html> <head> &l ...

What is the best approach to create a JavaScript search filter function spanning two pages?

Page1.html has a form with a drop-down menu containing options Color and Shape. There is also a submit button. Assuming Page2.html displays various shapes like Blue Square, Red Square, Blue Circle, Red Circle, is it feasible to create a JavaScript file th ...

Is it necessary for each React component to have its own individual stylesheet?

Looking for some advice on React as a newbie here. I'm wondering whether each React component should have its own stylesheet. For instance, if I have my main App component that gets rendered to the browser, is it sufficient to include a CSS file the ...

Hovering over an option in Vue-Bootstrap b-select

I'm working with the Vue-Bootstrap framework and I need to update the CSS rule for the 'option' tag when it is being hovered over. Here is my code snippet: jsfiddle option:hover { background-color: red; } Can someone please explain why ...