Html Bootstrap 3 - 可滚动的内容 div

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19676813/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 14:53:25  来源:igfitidea点击:

Bootstrap 3 - Scrollable content div

csstwitter-bootstraphtmlscrollgrid

提问by Per Aranda

I'm using Bootstrap 3 and I'm trying to make a scrollable content DIV. I have a grid with a left side navigation and a top bar and in the middle I have the content that should be scrollable.

我正在使用 Bootstrap 3,并且正在尝试制作可滚动的内容 DIV。我有一个带有左侧导航和顶部栏的网格,在中间我有应该可以滚动的内容。

It works when I use a fixed height on the content div...but I want to use 100% instead.

当我在内容 div 上使用固定高度时,它会起作用……但我想改用 100%。

<div  class="col-lg-12 col-md-12 col-sm-12" style="height:100%;overflow-y:auto;">
some content...
</div>

CSS:

CSS:

html,body
{
 height:100%;
 overflow:hidden;
}

How could I get this to work with height:100%;

我怎么能让它在 height:100% 下工作;

Thanks!

谢谢!

回答by hugocabral

You can add pre-scrollableclass for the div you want to scroll.

您可以为要滚动的 div添加pre-scrollable类。

If you search the .cssthere is a max-heightbut you cant edit. So you have sure it will maximize the page in the window for that max value.

如果你搜索.css有一个最大高度,但你不能编辑。因此,您确定它将最大化窗口中的页面以获得该最大值。

Hope it helps, i used the same for a one-page with scrollable divs.

希望它有所帮助,我对带有可滚动 div 的一页使用了相同的内容。