[英]Bootstrap Sidebar Not Scrollable 100% Height
我目前在屏幕的左侧有一个Bootstrap边栏。 height
设置为100%
。 但是,当内容超过屏幕底部时,它将无法滚动。
我看到了这个与堆栈溢出非常相似的问题。 其中一条评论提到这可能是由于我的身高设置为100%。
我试图将我的高度设置为100px,以测试内容是否可以滚动,并且可以正常工作。
所以我的问题是,有没有一种方法可以使边栏中的内容可滚动并将高度保持在100%
而不必设置特定的像素值?
编辑:
以下是#sidebar-wrapper
当前CSS。
#sidebar-wrapper {
overflow-y: scroll;
z-index: 1000;
position: fixed;
left: 175px;
width: 175px;
height: 100%;
margin-left: -175px;
overflow-y: auto;
background: #222222;
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
transition: all 0.5s ease;
}
更新:
经过特定于网站的代码之后。 固定位置的侧边栏需要CSS属性top:52px
,该属性偏移top:52px
的侧边栏以适应高度52px
和bottom:0px
的导航栏,该导航栏被添加以确保侧边栏扩展到浏览器窗口的底部。
#sidebar-wrapper {
z-index: 1000;
position: fixed;
left: 175px;
top: 52px;
bottom: 0px;
margin-left: -175px;
overflow-y: auto;
background: #222222;
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
transition: all 0.5s ease;
}
旧答案:
这是来自bootsnipp.com/的一些示例代码,以及一个简单的代码片段。 请参考下面的JSFiddle。
因此,如果代码以这种格式构造,则引导程序将在内部处理边栏滚动,如果您始终需要添加滚动,则将CSS属性overflow-y:scroll
到ID #sidebar-wrapper
下面的CSS是我在说的。
#sidebar-wrapper {
margin-left: -250px;
left: 250px;
width: 250px;
background: #000;
position: fixed;
height: 100%;
overflow-y: auto;
z-index: 1000;
transition: all 0.4s ease 0s;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.