CSS overflowing issue causing inability to reach bottom of div with scroll bars not functioning as anticipated

My objective is to create a layout featuring a sticky header and left sidebar, with a non-sticky DashboardBody (the green-bordered box) that can be scrolled through. When scrolling, I want the content at the top to disappear "under" the sticky header. The implementation involves styled-components, where the two boxes under the header are enclosed in a BelowNavContainer that utilizes flexbox.

The component ProjectContainer encompasses the entire view, including the header and sidebar. To ensure a scrollbar only appears on the DashboardBody section, I have set overflow: auto for it and overflow: hidden for the ProjectContainer. However, this approach prevents users from seeing the bottom of the DashboardBody, as well as the downward arrow on the scrollbar.

When attempting to resolve this issue by setting overflow: auto for the ProjectContainer, an unwanted extra scrollbar appears. While this allows me to reach the bottom of the DashboardBody, having dual scrollbars is not ideal.

I am seeking guidance on correcting this problem and achieving a single scrollbar solution. Despite specifying a height value, existing solutions related to overflow problems have not proved effective.

You can view a working demo here: https://codesandbox.io/s/overflow-woes-i4dww

Please note that CodeSandbox itself adds a scrollbar to the view, which may skew the appearance. When using webpack-dev-server on my local machine (via create-react-app), there is one less scrollbar than displayed in CodeSandbox.

Ultimately, I anticipate the DashboardBody to feature a scrollbar enabling users to scroll to the bottom of the div without requiring an additional scrollbar in its parent container, ProjectContainer.

Despite efforts, I am currently unable to access the bottom of the scrollbar within the DashboardBody without introducing another scrollbar to the enclosing ProjectContainer.

Answer №1

The issue lies within the BelowNavContainer Component.

You've specified its height as 100vh, but take into account that there is a header positioned above it. Therefore, the total height of the entire page becomes:

header Height + 100vh (BelowNavContainer height).

Additionally, since you have set the height of the parent component, ProjectContainer, to 100% with an overflow: hidden property, this causes the bottom part of the DashboardBody component to be hidden.

Solution:

To resolve this issue, adjust the height of the BelowNavContainer as follows: height: calc(100vh - 100px)

Where 100px represents the height of your header.

For a demonstration of the solution, please refer to this working demo.

Answer №2

The header on your page is set to 100px in height, while the content below spans the entire screen with a height of 100vh. To ensure that the bottom of the content aligns without the need for an additional scrollbar, consider adjusting the height of the content to: calc(100vh - 100px). Does this solution meet your needs?

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

Like button on Facebook within an unordered list (<ul>)

I'm having a headache with the Facebook button. I'm attempting to include all social buttons in one unordered list with "display: inline;" set on the list item elements. Check out the code below: <ul id="social" class="grid_3 alpha"> & ...

Maintaining selectedModel state in Material UI Datagrid Checkbox selection during Server-side pagination to ensure selected items are preserved when transitioning between pages

Utilizing Material UI's Data Grid and implementing server-side pagination with a custom Pagination Component. The issue I am facing is that when I select a checkbox on the same page, it works fine. However, when I change pages, my selectionModel reset ...

Ensure that FlexBox Columns have a height of 100% and vertically align their content

Having scoured through numerous questions and answers, I'm still stuck on why I can't achieve 100% height for certain flexbox columns. Specifically, trying to make the "Genre" column with one line of text match the height of the "Song & The A ...

Enhance your HTML audio player with added timeline functionality

I'm currently working on incorporating an HTML audio player into my project. I've managed to get the play/pause functionality to work, but now I'm stuck on adding a timeline feature. Additionally, I'm not sure how to implement the play/ ...

React Hook Form is experiencing an excessive amount of re-renders which can lead to an infinite loop. React sets a limit on the number

Currently, I am working on displaying a field named party. Once this field is selected, a list of products should be rendered. In my project, I am using React Hook Form along with the watch hook to keep track of changes. <FormProvider {...methods}> ...

What could be causing the error that keeps popping up when I attempt to create a Next app?

Trying to master Next.js has been a bit of a challenge for me. Every time I attempt to create an app, a network error pops up saying the request to https registry.npmjs.org/create-react-app failed due to connect ETIMEDOUT. It suggests that I may have a p ...

Challenges with Enzyme setup

I recently started using create-react-app and decided to incorporate testing into my project. Following the instructions on the create-react-app repo, I successfully installed Enzyme. For more information on Enzyme installation, you can check out this link ...

Fluid imitation pillars with a decorative outer edge

Looking to create a modern, sleek 2-column HTML5 interface with a left sidebar and main content area on the right. Backwards compatibility is not an issue as all users will be using the latest versions of Chrome or FF. The goal is to give the sidebar a ba ...

Ensuring that a header one remains on a single line

Within this div, I have set the width and height to be 250px. Specifically, the h1 element inside the div has a height of 50px. Users who are updating content on my website can input any text they desire within this box. However, when the text within the ...

Formatting text to automatically continue onto the next line without requiring scrolling through long blocks of

I have a unique Angular project with a terminal interface that functions properly, maintaining a vertical scroll and automatically scrolling when new commands are entered. However, I am struggling to get the text within the horizontal divs to wrap to the ...

Issue with props not being updated when Redux store state changes in Reactjs

When I make a call to the 'getGame' method after retrieving data from an API and updating the store, the props of my component do not update. However, everything works fine when using the 'getGames' method. I have confirmed that the ac ...

What is the best way to combine the existing array data with the previous array data in JavaScript?

I am implementing server-side pagination in my MERN project. Let's say I retrieve 100 products from the database and want to display only 30 products, with 10 products per page. When a user navigates to the 4th page, I need to make another API call to ...

JS custom scrollbar thumb size issues in relation to the scroll width of the element

I recently implemented a custom scrollbar for a component on my website. To determine the length of the scrollbar thumb, I use the formula viewportWidth / element.scrollWidth;. This provides me with a percentage value that I then apply to the thumb elemen ...

Design images with rounded corners using CSS

I'm looking to design an image avatar similar to the contact avatars on Skype. Can someone assist me with this? I have tried using border radius-boundary, but I haven't had much luck. ...

Encountered a MongoDB connection issue during deployment on ZEIT platform

Hey there! I'm a newcomer to React and I've been working on deploying my app on Zeit. Everything seems to be going smoothly, except for one issue that has popped up on Zeit regarding the error: /usr/src/app/bundle/programs/server/node_modules/ ...

Testing a React component that uses useParams: A step-by-step guide

I've been working on creating a BBS App using TypeScript, React, React Router, and React Testing Library. However, I've encountered an issue where a component utilizing useParams is not passing a test. Interestingly, it seems to be working correc ...

Ways to divide the vuetify-text-field-label into two lines

My vuetify text field has a label that is too long for mobile devices. I am wondering if there is a way to automatically wrap the text. I attempted using div and p, as shown in this codepen link <div id="app"> <v-app id="inspire ...

The element type provided is not valid: it was expecting a string but received undefined. Please review the render method of AnimatedComponent in ReactNavigation

I've been facing an issue for the past few days with ReactNavigation v6+. While there are multiple questions and answers about the invalid element type, none of them seem to be working with this specific example: The problem arose after integrating t ...

Using 'if' conditions in Reactjs: A step-by-step guide

Working with Reactjs in the nextjs framework, I have received user data that includes the "category name (cat_name)" selected by the user. Now, I need to display that category in a dropdown menu. How can I achieve this? The current code snippet showcases ...

Issues with Google fonts not displaying properly on WordPress site

I'm just starting out with Wordpress and I'm using the html5blank theme to bring in my stylesheets. However, I've run into an issue where the google fonts are not being applied on my wordpress site. In my header.php file, I have included th ...