![](/img/trans.png)
[英]Bootstrap - how to make vertical sidebar with fixed width/not scrollable but still responsive?
[英]How to keep sidebar layout fixed, not scrollable with bootstrap?
我正在尝试制作一个简单的管理面板。 我添加了一个侧边栏作为布局。 我想保持它的固定。 但是当我向下滚动页面时,我的侧边栏也会向下滚动。 这是它在页面开头的样子:
当我向下滚动页面时:
我想保持它如图 1 所示,即使页面向下滚动。 siderbar的开头是这样的:
<ul class="navbar-nav bg-gradient-primary sidebar sidebar-dark accordion" id="accordionSidebar" style="max-height:100%">
编辑:我试过.navbar-nav { position: fixed; left: 0; top: 0; bottom: 0, width: 150px; }
.navbar-nav { position: fixed; left: 0; top: 0; bottom: 0, width: 150px; }
.navbar-nav { position: fixed; left: 0; top: 0; bottom: 0, width: 150px; }
结果是:
试试这个方法
<div class="container-fluid">
<div class="row">
<div class="col-md-3 px-1 bg-dark position-fixed">
...
</div>
<div class="col-md-offset-3 col-md-9 col-sm-12">
<h1>Main Area</h1>
...
</div>
</div>
</div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.