简体   繁体   English

可滚动内容内的可滚动内容

[英]Scrollable content inside of scrollable content

I was wondering if I could put scrollable content inside of scrollable content. 我想知道是否可以将可滚动内容放入可滚动内容中。 I have something like this: 我有这样的事情:

 <div style="overflow-y: auto; padding: 10px"> <div layout="column"> <h3 style="margin: 5px">Header 1</h3> <h3 style="margin: 5px">Header 2</h3> </div> <div layout="column" layout-align="center center" style="height: 100%"> <div layout="column" layout-align="center center" style="width: 70%; height: 100%; overflow-y: auto"> <div layout="column" style="width: 100%"> This content could be any height but should start scrolling when it gets larger than parent div </div> </div> </div> </div> 

So far I can only get the outer div to scroll. 到目前为止,我只能使外部div滚动。 Is there a way to get both scrollable (without setting a specific pixel height)? 有没有办法让两者都滚动(无需设置特定的像素高度)?

If the parent container will have 100% height - you will not have any scrollbar, and if it's child-element will have 70% if it's parent - the same goes there. 如果父容器的高度为100%-您将没有任何滚动条,并且子容器的父容器将为70%-相同。

If you make the parent container a fixed height, you will have them both scrolled: 如果将父容器设置为固定高度,则将它们都滚动:

 <div style="overflow-y: auto; padding: 10px; border: 1px solid red; height: 500px;"> <div layout="column"> <h3 style="margin: 5px">Header 1</h3> <h3 style="margin: 5px">Header 2</h3> </div> <div layout="column" layout-align="center center" style="height: 100%"> <div layout="column" layout-align="center center" style="width: 70%; height: 100%; overflow-y: auto;border: 1px solid blue;"> <div layout="column" style="width: 100%"> This content could be any height but should start scrolling when it gets larger than parent div This content could be any height but should start scrolling when it gets larger than parent div This content could be any height but should start scrolling when it gets larger than parent div This content could be any height but should start scrolling when it gets larger than parent div This content could be any height but should start scrolling when it gets larger than parent div This content could be any height but should start scrolling when it gets larger than parent div This content could be any height but should start scrolling when it gets larger than parent div This content could be any height but should start scrolling when it gets larger than parent div This content could be any height but should start scrolling when it gets larger than parent div This content could be any height but should start scrolling when it gets larger than parent div This content could be any height but should start scrolling when it gets larger than parent div This content could be any height but should start scrolling when it gets larger than parent div This content could be any height but should start scrolling when it gets larger than parent div This content could be any height but should start scrolling when it gets larger than parent div This content could be any height but should start scrolling when it gets larger than parent div This content could be any height but should start scrolling when it gets larger than parent div This content could be any height but should start scrolling when it gets larger than parent div This content could be any height but should start scrolling when it gets larger than parent div This content could be any height but should start scrolling when it gets larger than parent div This content could be any height but should start scrolling when it gets larger than parent div This content could be any height but should start scrolling when it gets larger than parent div This content could be any height but should start scrolling when it gets larger than parent div This content could be any height but should start scrolling when it gets larger than parent div This content could be any height but should start scrolling when it gets larger than parent div This content could be any height but should start scrolling when it gets larger than parent div </div> </div> </div> </div> 

If you don't want to use specific pixels you can use the vh instead (viewport-height) 如果您不想使用特定的像素,则可以改用vh (viewport-height)

 <div style="overflow-y: auto; padding: 10px; border: 1px solid red; height: 100vh;"> <div layout="column"> <h3 style="margin: 5px">Header 1</h3> <h3 style="margin: 5px">Header 2</h3> </div> <div layout="column" layout-align="center center" style="height: 100%"> <div layout="column" layout-align="center center" style="width: 70%; height: 100%; overflow-y: auto;border: 1px solid blue;"> <div layout="column" style="width: 100%"> This content could be any height but should start scrolling when it gets larger than parent div This content could be any height but should start scrolling when it gets larger than parent div This content could be any height but should start scrolling when it gets larger than parent div This content could be any height but should start scrolling when it gets larger than parent div This content could be any height but should start scrolling when it gets larger than parent div This content could be any height but should start scrolling when it gets larger than parent div This content could be any height but should start scrolling when it gets larger than parent div This content could be any height but should start scrolling when it gets larger than parent div This content could be any height but should start scrolling when it gets larger than parent div This content could be any height but should start scrolling when it gets larger than parent div This content could be any height but should start scrolling when it gets larger than parent div This content could be any height but should start scrolling when it gets larger than parent div This content could be any height but should start scrolling when it gets larger than parent div This content could be any height but should start scrolling when it gets larger than parent div This content could be any height but should start scrolling when it gets larger than parent div This content could be any height but should start scrolling when it gets larger than parent div This content could be any height but should start scrolling when it gets larger than parent div This content could be any height but should start scrolling when it gets larger than parent div This content could be any height but should start scrolling when it gets larger than parent div This content could be any height but should start scrolling when it gets larger than parent div This content could be any height but should start scrolling when it gets larger than parent div This content could be any height but should start scrolling when it gets larger than parent div This content could be any height but should start scrolling when it gets larger than parent div This content could be any height but should start scrolling when it gets larger than parent div This content could be any height but should start scrolling when it gets larger than parent div </div> </div> </div> </div> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM