Issue
Context
I have a navbar with a fixed height. I want the space underneath to fill the rest of the screen vertically. I also need to have a fixed height because I have a container inside the page that has a list that is scrollable but without scrolling the whole page overflow: hidden
The Problem
When I set a height on all parent elements of 100%
I get a vertical scrollbar. I found some answers on SO about "margin collapse" but nothing that could solve my problem.
100vh
also won't work without having a scrollbar.
Here is the css for setup the height (#__next is just a div where next.js renders the page):
html,
body,
#__next {
height: 100%;
width: 100%;
}
The navbar is just a fixed pixel height, and the space below has height: 100%
Here is a screenshot that shows the vertical scrollbar:
I can't find any problems on the chrome inspector.
This is how it should look (design file):
How to solve this? I need to have both containers from screen "SippetPanel" and "SnippetContent" to take the remaining height without adding a scrollbar. It should also work to have a inner scrollbar with overflow hidden (later on when there are many items in the list like from design file).
Solution
Be aware that percentual heights refer to the height of the parent.
You can use calc()
to solve your issue:
#__next{
height: calc(100% - navbarpx);
...
}
For the padding issue you can look into border-box.
Answered By - Lain
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.