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

Choose from a variety of options using Select and Checkbox components, but limit your choices to a maximum selection

Looking to implement the Select and Checkbox components from MUI with the ability for users to select multiple options. I want to limit their selection to a maximum of 3 choices, but I can't seem to find the props to set this restriction. Is there a w ...

Issue encountered where Moment locale functionality is working in local development environment, but not functioning properly in the

My application built with Next.js requires displaying the date in Bengali instead of English. The issue arises after running the build command 'build:next build' where the production version displays the date in English (e.g. '20 January, Su ...

Text inputs are not expanding properly when placed within the same Grid container as a react-select dropdown component

Recently, I encountered an issue that only occurs when using Chrome (Version 76.0.3809.132). The problem arises in a simple dialog box consisting of a material ui (v4.3.3) Grid, several TextFields, and two react-select (v3.0.4) Select boxes. The container ...

Tips for creating gaps between wells within a Bootstrap row

Utilizing bootstrap, I am aiming to position two wells side by side without them being squeezed right next to each other. However, I am encountering some issues with achieving this. Here's the code snippet I am currently using: <div class="contai ...

Troubleshooting CSS Navigation Drop Issue Specific to Google Chrome. Seeking Feedback on Rails Tutorial Experience

I'm currently working my way through the amazing Rails Tutorial and have encountered a problem with the Navigation bar dropping down into the body of the page, but this issue only seems to occur in Chrome (I'm using Linux, Ubuntu 10.10). I'v ...

The code functions perfectly on JSfiddle, but for some reason it halts when implemented on

Unfortunately, the code that was working perfectly on JSfiddle seems to be encountering issues when implemented on a regular HTML site. The content loads fine but there seems to be an error with the preview function after selecting an image. We have colla ...

Encountering the error "ERR_HTTP_HEADERS_SENT" after attempting to send emails through the next.js API

Currently, I am in the process of generating users through the next.js API. However, my goal now is to utilize SendGrid for sending emails. The setup is in place, but unfortunately, I'm encountering the following issue: event - compiled successfully ...

Making an Axios request with parameters

I am facing an issue where my parameter articleid is not being passed to the route /createAnswer. When I log articleData._id, it shows the correct ID (e.g., 60b4f5d8c8be1d4cb0cdd6ca) that I want to pass to the route /createAnswer. const createAnswer = () = ...

The error message "React/display-name error: Component definition does not include a display name

When trying to upload my project to Vercel NextJS, I encountered an error stating that the display name 'react' is missing. After researching online, it seems this error occurs when a function is not exported correctly. Can anyone help me with th ...

Using an if statement within a map function in a React component

I am facing a challenge with using an if statement inside a map function without changing the return value. Here is my code snippet: this.example = this.state.data.map((item) => { return( <div> {if(1 + 1 == 2){ dat ...

Looking to showcase website HTML code by simply clicking on a banner image?

I am looking to implement a feature where banner HTML code is displayed in a popup on website when the banner is clicked. For instance, an example of a banner could be: <img src="https://myweb.com/images/banners/1.gif"> Upon clicking the banner im ...

The page loads successfully at first, but upon refreshing, a 404 error occurs when using Zeit, Nextjs, and now

After recently updating from now v1 to v2, I encountered an issue where my pages would return a 404 error when reloading after pushing to production using now --prod. While everything worked fine locally with now dev, the routing seemed to be causing confu ...

Facing issues with @material-ui icons not being properly resolved on Windows OS

I am trying to incorporate Material UI into my React code, but I keep running into an issue. The error message reads: Module not found: Can't resolve '@material-ui/icons/Search' in 'C:\Users\Dominik\code\facebook&bs ...

What is the best approach for testing a component that makes use of React.cloneElement?

My main component fetches children using react-router in the following manner: class MainComponent extends Component { render() { return ( <div> {React.cloneElement(children, this.props.data)} </div> ) } } I a ...

Is there a way to implement a scrollable feature for AutocompleteInput and SelectArrayInput components?

Currently, I am utilizing the AutocompleteInput and SelectArrayInput components from the AOR framework. It seems that when selecting from a large pool of items, the menu does not display properly on the screen. Is there a way to make the item list scrolla ...

Animating Divs with jQuery to Expand their Size

I am currently designing a services page for my portfolio website. The layout consists of three columns, with the central column containing a large box and the left and right columns each containing three smaller boxes. These smaller boxes function as clic ...

The iframe is not large enough to contain all the HTML content

I'm encountering a problem with a website I'm currently developing - specifically, I am struggling to embed an HTML document into an iframe in a manner that fills the entire page. Additionally, I am utilizing Angular to retrieve the HTML document ...

Using WHERE clause effectively in an UPDATE statement in Node.js

Today, I have encountered an issue with my code that I would like to address. The problem lies in the PUT method where it currently updates all rows in the table instead of just the matched rows. How can I ensure that only the matched rows are updated? ...

Differentiate between minimum and maximum values on ion-range sliders with discrete color options

I am currently working on customizing the theme of my ionic app, specifically trying to assign different colors to the min and max knobs on an ion-range component. At the moment, I am only able to apply a single HTML property called "color" to the selector ...

Validate prop must consist of one of two functional components

I am looking to ensure that a prop can only be one of two different components. Here is what I currently have: MyComponent.propTypes { propA: PropTypes.oneOfType([ PropTypes.instanceOf(ClassComponentA) PropTypes.instanceOf(ClassCompon ...