Why is the Footer component in Next.js Styling not staying at the bottom of the screen as intended?

Why is the Footer component not at the bottom of the screen in Next.js Styling?

import Head from "next/head";

import Navbar from "./Navbar";
import Footer from "./Footer";

const layoutStyle = {
  display: "flex",
  flexDirection: "column",
  height: "100%",
  width: "100%"
};

const Layout = props => (
  <div className="Layout" style={layoutStyle}>
    <Head>
      <title>Oracle</title>
      <meta name="viewport" content="width=device-width, initial-scale=1" />
      <meta charSet="utf-8" />
    </Head>
    <Navbar />
    <div>{props.children}</div>


    <Footer/>
  </div>

);

export default Layout;

footer

import React, { Component, Fragment } from "react";


class Footer extends Component {
    render() {
        return (
            <div className="bg-gray-100">
                <div className="bg-gray-100 container mx-auto px-6 pt-10 pb-6" >
                    >
                    © Oracle Corp. All rights reserved.
        </div>
            </div>
        )
    }
}

export default Footer;

This issue seems to be related to Next.js, but I'm unsure how to resolve it :/

I suspect it has something to do with how Next.js sets up each page.

Thank you for your help,

Answer №1

Experiment with changing the styling of the __next element enclosing the app.

https://i.sstatic.net/f8yWS.png

#__next {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 100vh;
}

Answer №2

After investigating further, I successfully replicated the issue and resolved it by adjusting the positioning of the footer to the bottom of the page. This was achieved by incorporating an inline style within the Footer component using

style={{ position: "absolute", bottom: 0, width:"100%" }}
. The updated component code is as follows:

import React, { Component, Fragment } from "react";

class Footer extends Component {
  render() {
    return (
      <div style={{ position: "absolute", bottom: 0, width:"100%" }} className="bg-gray-100">
        <div className="bg-gray-100 container mx-auto px-6 pt-10 pb-6">
          > © Oracle Corp. All rights reserved.
        </div>
      </div>
    );
  }
}

export default Footer;

Answer №3

const footer = (
  <div style={{ position: "absolute", bottom: 0, width:"100%" }} className="bg-gray-100">
    <div className="bg-gray-100 container mx-auto px-6 pt-10 pb-6">
      > © MegaCorp Ltd. All rights reserved.
    </div>
  </div>
);

It did the trick for me.

Answer №4

When working with Next.js, you can set a global style for the

<div class="container">
in the 'pages/_app.js' file.

        <style jsx global>
          {`

            .container {
              display: flex;
              flex-direction: column;
              min-height: 100vh;
            }

          `}
        </style>

Answer №5

For those who have organized their components within a src folder, it is important to update the Tailwind config file. Before:

  content: [
    "./pages/**/*.{js,ts,jsx,tsx}",
    "./components/**/*.{js,ts,jsx,tsx}",
  ],

After:

  content: [
    "./pages/**/*.{js,ts,jsx,tsx}",
    "./src/components/**/*.{js,ts,jsx,tsx}",
  ],

This simple adjustment solved my issue!

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

Uploading files to an external node server using NextJS proxy functionality

In my setup, I am using NextJS along with an external Node/Express Server to manage file uploads. The current configuration allows for direct browser-to-server uploads, but I am looking to transfer the upload process from Next to the external server throug ...

Warnings from Next.js regarding the use of images

Whenever I use an image like this in my project, I keep receiving warnings in the client console: <Image src="/login/rightSideMainImage.svg" alt="blue_ellipse" width={760} height={760} /> The ...

Update the content of the widget

Currently, I am utilizing the following script to display NBA standings: <script type="text/javascript" src="https://widgets.sports-reference.com/wg.fcgi?script=bbr_standings&amp;params=bbr_standings_conf:E,bbr_standings_css:1&amp"></sc ...

Creating a unique post type in Wordpress

Currently, I am in the process of converting a Bootstrap one-page template into a WordPress template. My goal is to incorporate a custom post type that will display items in the services portfolio while maintaining the same CSS styling. Here is the code sn ...

The type 'EventTarget & HTMLTextAreaElement' does not contain the property 'files'

When trying to call a method in React TypeScript on the onChange Event of a MUI Input field, an error is encountered. The error message received is: Type '(event: { target: { files: any[]; }; }) => void' is not assignable to type 'Chang ...

An error has occurred in the Shadow Dom due to the inability to access the property 'style' of an

While working on a component using shadow DOM, I encountered the following error in the console: "Cannot read property 'style' of undefined". This issue seems to be related to my HTML code in PHP. The main challenge I am facing is figuring out ho ...

What could be causing my elements to shift out of place?

Here is the box I created: BOX Now, I want to position another box near the input of the BET box. <div id="x2"></div> <!-- HTML ---> /* CSS */ #x2{ width: 40px; height: 40px; background: cornflowerblue; } The layout after ...

Utilize Material UI to include both an image and text within a checkbox label for an enhanced display

What is the best way to display an image along with text as a label for a checkbox in Material UI and React? Here is my current code snippet: <FormControlLabel control={ <Checkbox checked={false} onChange={this.handleChange('')} value= ...

Unable to establish React API communication on cloud-based IDE for MERN Stack development

Exploring the MERN stack through this informative tutorial: https://medium.com/@beaucarnes/learn-the-mern-stack-by-building-an-exercise-tracker-mern-tutorial-59c13c1237a1 I've opted to use goorm IDE, a cloud platform similar to cloud 9 IDE. As I pro ...

Encountered an error loading resource: server returned a 404 status code while utilizing Angular framework and deploying via GitHub Pages

Currently facing an issue with my Angular website deployment on Github Pages, receiving a console error "Failed to load resource: the server responded with a status of 404 ()" at "home: 1". This error specifically seems to be related to the app.component ...

What steps should I take to update the state of this navbar?

Trying to understand why the prop I want to pass won't work with the toggle function: function custToggle({e}){ e.custOrFalse= !e.custOrFalse; var custButton='cust page' if ( e.custOrFalse==true ) { custButton='cust lo ...

How can I use the store command to retrieve the href value of a link using a css selector in Selenium?

Is there a way to store a URL from a link using CSS instead of xpath? store //tr[td[contains(.,'6 Day')]][1]/td[8]/a@href my_var open $my_var If so, how can I achieve this goal with css? I managed to use the following locator: store css= ...

The concept of columns nested within columns

My goal is to create three new columns within the center column on my webpage. However, when I attempt to nest them, they end up stacking at the bottom of the center column instead of staying inside it. Is there a way for the center column to act as a back ...

Dealing with memory leaks in React's componentWillMount

I recently came across a video that discussed how the componentWillMount method can potentially lead to memory leaks. The video can be found here: https://www.youtube.com/watch?v=Fgd2ivSnXXo In order to test this theory, I checked for listeners using con ...

Running a dual POST request simultaneously

I need help in understanding why I am unable to successfully post both of these requests. Can someone please guide me on what might be causing the issue? app.post("/api", async (req, res) => { try { let response = await axios.post("/schedules/s ...

Differences in row padding when transitioning from Bootstrap 3 to Bootstrap 4

One thing I've noticed is that when utilizing Bootstrap 3, the use of div.row would automatically create a vertical spacing between rows which was quite appealing. However, upon transitioning to Bootstrap 4, this automatic spacing seemed to disappear. ...

What is the best way to customize arrow designs in a React Slick Slider?

I am struggling to customize the arrows in react-slick with my own PNG images. Despite my efforts, the images appear distorted on the screen as they are automatically set to a width and height of 20px instead of their actual size of 17x27px. I have experim ...

What is the best way to center align and add an icon to the header in Ionic?

How can I center align an "ion-ios-arrow-up" icon in the header of my Ionic app, similar to the concept shown below? This is my HTML template: <ion-view cache-view="false" view-title="Historical HPP"> <ion-nav-bar class="nav-title-slide-ios7 ...

What is the process for incorporating a side group input with Bootstrap?

description of image here I am looking to add 4 small input boxes next to the third input box. Please refer to the image I have attached for reference. In the image, I have included 4 boxes. I am specifically looking for a similar layout. ...

Ensuring the validity of float and non-empty values in JavaScript

Embarking on the journey of web development, I'm delving into basic applications. My current project involves creating a straightforward webpage to add two numbers and implementing preliminary validations - ensuring that the input fields are not left ...