繁体   English   中英

具有动态高度的垂直滚动div

[英]Vertically scrollable div with dynamic height

以下是我的HTML:

 .wrapper { height: 90%; overflow: hidden; display: flex; flex-direction: column; } .non-scrollable-container { flex-shrink: 0; flex-grow: 0; max-width: 100%; width: 100%; } .scrollable-container { overflow-y: auto; overflow-x: hidden; width: 33.33%; display: inline-block; } 
 <div class="wrapper"> <div class="non-scrollable-container"></div> <div class="scrollable-container"></div> <div class="scrollable-container"></div> <div class="scrollable-container"></div> </div> 

现在,“ non-scrollable-container” div的高度是动态的,但不能滚动,并且具有100%的宽度。

所有三个“ scrollable-container” div都应内联设置,也可以单独滚动。 我正在尝试将它们内联,但无法做到。 如何在flexbox中内联设置它们?

 .wrapper { display: flex; flex-direction: row; flex-wrap: wrap; } .non-scrollable-container { display: flex; flex-direction: row; width:100%; background-color:#ccc; height:auto; } .scrollable-row { display: flex; flex-direction: row; width:100%; margin-top:10px; } .scrollable-container { display: flex; flex-direction: column; width:33.33%; background-color:#ccc; height:100px; overflow:auto; padding:5px; } 
 <div class="wrapper"> <div class="non-scrollable-container"> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. </div> <div class="scrollable-row"> <div class="scrollable-container"> It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. </div> <div class="scrollable-container"> It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. </div> <div class="scrollable-container"> It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. </div> </div> </div> 

试试这个代码,它对你有用。 如果您有任何问题,请通知我。

暂无
暂无

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

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