Footer displays within the content section

Currently, I am utilizing Next.js and antd's layout components to create a dashboard-style page using their Layout component. However, I have encountered two issues related to styling (CSS) in this setup:

  • Footer appearing within the Content: I am working on a modified version of the fixed-sider example from the antd documentation. The Footer is ending up between the Content components. It seems like a styling issue, but I am struggling to pinpoint the exact problem. What kind of styling issue should I be focusing on to resolve this?
  • Scrolling behavior: When fully expanded, the Sidebar cannot be scrolled all the way to the end. Instead, the browser window scrollbar needs to be used to navigate through the fixed sidebar content completely. Is there a way to disable the window's scrollbar (which also affects the appearance)? If disabling it is not an option, how can I make the sidebar scrolling smooth and independent from the browser window scrollbar?

I have recreated the problem in this CodeSandbox demo.

https://i.stack.imgur.com/6lGk5.png

Answer №1

The issue at hand is a result of the interaction between multiple <Layout /> components and their children, particularly when they have varying heights. It seems that child Layout and Content components inherit height from the parent Layout, or at least have a smaller height.

Your current Layout setup looks like this (pseudocode):

<Layout>
  <Layout restrictedHeight >
    <Layout inheritedRestrictedHeight>
      <Content inheritedRestrictedHeight >
        <div unrestrictedHeight />
      </Content> //Content "height" ends here
      <Footer fixedPosition /> //Always begins where Content ends
      //Div "height" ends here
    </Layout>
  </Layout>
</Layout>

The footer is implemented in such a way that it is placed after the Content in the DOM, but since the large div's height is not restricted, it extends far below the Content container. This results in the Footer component appearing to render within the content.

The issue lies with this line:

<Layout hasSider={true} style={{ height: "100vh", marginTop: 64 }}>

By setting the height property to 100vh (100% view height), you are effectively limiting the layout to the current pixel count available on the screen vertically. To address this, set the height to 100% instead of 100vh:

<Layout hasSider={true} style={{ height: "100%", marginTop: 64 }}>

This adjustment resolves the double scroll bar issue as well.

UPDATE AND SOLUTION FOR NONSCROLLING SIDEBAR

To prevent the sidebar from scrolling, give the Sider component a specific height equivalent to what is visible on the screen.

The component renders in the DOM with a height based on its contained content. To achieve a non-scrolling sidebar, limit the height to the space below the navigation bar by calculating 100vh minus the nav bar's size in the CSS/LESS for the sidebar: height: calc(~"100vh - 64px"); and ensure overflow-y is set to auto.

.sidebar {
  overflow-y: auto;
  overflow-x: hidden;
  height: calc(~"100vh - 64px");
  position: fixed;
  left: 0;
} 

For an updated solution, refer to this codesandbox.

In future queries, it is recommended to focus on one main question for better responses.

Answer №2

The solution is to reposition the footer between lines 119 and 120, ensuring it aligns with the sidebar within the same container.

Answer №3

Regrettably, I am unable to make changes to your script. Upon reviewing it, my recommendation would be to insert the following code snippet:

<Footer style={{ textAlign: "center" }}>
            Ant Design ©2018 Created by Ant UED
          </Footer>

After the layout 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

Resizing Your WordPress Header Logo

Hi there! I am struggling to resize the logo in the header of my website www.cookingvinyls.com. Despite my efforts, I can't seem to override the hardcoded version. I attempted to modify the width and height lines in header.php, but unfortunately, it ...

The MinWidth property in ColumnDefinition is not functioning as expected

Currently, I am encountering an unusual issue while using a Grid in WPF (XAML) and setting the MinWidth property in a ColumnDefinition. When I have 9 ColumnDefinitions with 'Width="*"' specified for each one, and then apply the MinWidth property ...

Converting HTML content into a single string simplifies data manipulation and extraction

exampleHTML=" This is sample HTML code that needs to be converted into a string using JavaScript

" I am looking to transform it into a single string format like str="This is sample HTML code, that needs to be converted into a string, usin ...

Angular 2 Component attribute masking

In my Angular 2 component called Foobar, I have defined a property named foobar: import { Component, OnInit } from '@angular/core'; @Component({ selector: 'app-foobar', templateUrl: './foobar.component ...

Having trouble loading styles in Vue after publishing to npm

I'm currently using vue-cli3 for the npm publication of a Vue component. Below are my build scripts: "package-build": "eclint fix && vue-cli-service build --target lib --name @xchat-component/chat-component ./src/index.ts & ...

What could be causing the lack of value appearing after I clicked the button?

Setting the value for the array of images as an empty string does not return the expected result. When I move one of the 4 images and click the button, I anticipate a new array with the information of one of the four images including src, x, and y coordina ...

The overflow scroll feature seems to be malfunctioning and not working as intended in the

I'm trying to implement the overflow scroll property in a div to display a scroll bar for the user, but I'm facing issues. I'm unsure what the problem could be. The code I'm working with can be found here : http://fiddle.jshell.net/Gg ...

What is the best way to vertically flip a background image that is repeating along the y axis in CSS?

I am in the process of developing a mobile web app and I need assistance with flipping the background image when it repeats along the y-axis. Can someone guide me on how to achieve this using CSS or JavaScript? https://i.stack.imgur.com/b107V.jpg var el ...

The dropdown list is nowhere to be found in the page source when using Selenium

Currently, I am engaged in web scraping using Selenium. Successfully locating the input box and entering ID numbers is no issue. Yet, a roadblock presents itself - there is no submit button linked to the search bar. Once the numbers are inputted, the box a ...

What are the best practices for utilizing the React constructor?

In my React Native project, I am dealing with a small array of objects containing IDs. The specific ID I need is retrieved from the navigation router and cannot be accessed through Redux selector. In order to fetch this data at the component level, I hav ...

What's the best way to align three images in a row?

I am having trouble centering three social media icons next to each other. I can't seem to figure out the proper way to do it. https://i.stack.imgur.com/Zf5p9.png <div class="maintext flipInX animated"> <div class="socials wow bounce an ...

Is Next.js considered a single-page application or an SPA?

Traditional React applications are commonly referred to as Single Page Applications (SPAs) because they typically consist of only one html page, the index.html. However, Next.js differs from this convention. So, is it accurate to label a Next.js applicat ...

Encountering issues with link button redirection

I have a question regarding a Link element and CustomButton element with an onClick handler. < Link to = "/dashboard" style = { linkStyles } > < CustomButton text = "Login" onClick = { handleSubmit } /> < /Link> The code ...

A guide on accessing the content of two p tags in React by utilizing the useState hook in ReactJs

I am currently working on retrieving the values of two p tags simultaneously to send those values to the backend. This is my useState declaration: const [isProposal, setIsProposal] = useState({ contractorName: "", newProposal: "" }); c ...

What should be displayed if there are no search results?

My form for filtering a database is working perfectly in the first section: $result=$dbh->prepare("SELECT * FROM performers WHERE accent='$txt_accent' AND hair='$txt_hair' AND gender='$txt_gender' AND location='$txt_l ...

What could be causing my React .map to display duplicate results after fetching data from an API?

I encountered an issue while fetching single type data from a strapi API using React .map method. The problem is that the single returned content appears twice in the output: { Object.values(objecthere).map(({ }) => )} I'm not sure what's cau ...

Steps to include a title next to a progress bar:

Is there a way to achieve something like this? I attempted to use bootstrap but I ran into an issue where the title was slightly misaligned below the progress bar. Can someone offer assistance with this matter? Apologies if this has been asked before. H ...

What is the best way to ensure an image is shown in full screen exclusively on mobile devices?

My goal is to have two different site templates, one for desktop (which is already good) and one for mobile. For the mobile template, I want it to display only an image that fills the entire screen. The image should take up all the available space in term ...

"Exploring the World of Mobile Development and Screen Size

Currently, I am in the process of creating a basic mobile website that can be accessed through a QR code leading to the page linked below. However, I have encountered an issue where viewing it on my Android or Apple phone results in excess width. Any advic ...

Looking to align a radio button in the middle of an inline-block?

Is it possible to center a radio button within an inline-block? I have provided a demo on JSFiddle that displays the current layout and how I envision it should appear. Check out the demo here Here is the code snippet in question: <span style="widt ...