試圖實現具有自動最大高度的div,以便當div中的列表非常長時,它不會強制整個頁面滾動,而是延伸它的高度儘可能低,因爲它可以在不使頁面滾動的情況下進行,並且在div本身內具有滾動條。目前,它的最大高度爲800px。這應該是自動設置,取決於瀏覽器視口分辨率。基於窗口大小的可滾動div上的動態最大高度
http://plnkr.co/edit/vt2tvVAErdpmPRkg1txd?p=preview
<body>
<div class="container">
<div class="row">
<div class="col-md-8">
<div class="panel panel-body panel-primary">
MainContent
</div>
</div> <!-- /.col-md-8 -->
<div class="col-md-4">
<div data-spy="affix">
some list here
<div style="max-height:800px;
overflow-y: auto; overflow-x: hidden; margin-top: 5px">
<div class="panel panel-body panel-default">
another list here, but this div should have an auto max height so that when the list is really long, it does not force the entire page to scroll, but instead extends its height to as far low as it can without making the page scroll, and have a scrollbar within the div itself. Currently, it is set with max-height of 800px. This should be autoset depending in browser viewport size.
</br>
</br>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
http://plnkr.co/edit/vt2tvVAErdpmPRkg1txd?p=preview – user2580209
我相信這是工作,但使用後不最大高度踢入。在加載時,沒有滾動可用。 – user2580209
好的,我刪除了詞綴,現在最大高度可以在頁面加載時完美設置。出於某種原因,詞綴只有在您在頁面上進行大小調整等操作時纔會啓用。 – user2580209