簡體   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