How to set a direct parent div's height, to height of scrollbar?
See original GitHub issueHello!
So the issue I face is simple yet a little confusing for me.
I used the basic example in the repo to create a list of 10,000 numbers and assigned parentScroll to the window, which is successfully being virtually scrolled.
Then I have nested the list into a card (having a card in the back of the list is a design necessity):
<mat-card class="custom-card">
<virtual-scroller #scroll [items]="myItems" [parentScroll]="scroll.window">
<div *ngFor="let item of scroll.viewPortItems">{{item }}</div>
</virtual-scroller>
</mat-card>
But even with height: 100% and flex:1, it shows the card like this:
As highlighted in the console, document.documentElement.scrollHeight only shows 696, which is in reality the clientHeight.
In other words, is there any way to expand this card’s height to fit all the content? Is there any property from ngx-virtual-scroller I could use? And how?
Issue Analytics
- State:
- Created 3 years ago
- Comments:5
Top Results From Across the Web
Define scroll div height by parent. Any tips? - Stack Overflow
and I need to place a #footer element below and let the top remaing space to a scrollable div, but is not possible...
Read more >height - CSS: Cascading Style Sheets - MDN Web Docs
The height CSS property specifies the height of an element. By default, the property defines the height of the content area.
Read more >Nesting and overflow - Mockupless
In HTML, create a flex parent container. Make it full-screen using height: 100vh . Paste the result of the task in the flex:...
Read more >CSS Height Full Page: CSS gotcha: How to fill page with a div?
A very common practice is to apply height: 100vh and width: 100vw to <body> directly... ... In this case, we can even keep...
Read more >Element size and scrolling - The Modern JavaScript Tutorial
Setting scrollTop to 0 or a big value, such as 1e9 will make the element scroll to the very top/bottom respectively. Don't take...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Work around works for me. Idea to get it work not with fixed pixel you have to set a height on each parent: https://stackoverflow.com/questions/31728022/why-is-percentage-height-not-working-on-my-div/31728799#31728799 But it’s even harder as your workaround… it would be nice if the virtual-scroll-element has a property so own calculation is not needed.
Is this a solution to our problem? -> https://github.com/rintoj/ngx-virtual-scroller/pull/447
I’d like to know if anyone has tried this out to solve our particular issue.