使用 Bootstrap,我有一个网格列 class="col-lg-3",我想把它放在位置:固定的位置,而另一个 .col-lg-9 是正常位置(可滚动浏览页面)。
<div class="row">
<div class="col-lg-3">
Fixed content
</div>
<div class="col-lg-9">
Normal scrollable content
</div>
</div>
就像 LifeHacker.com 中的左栏一样。 您会发现,无论我如何滚动页面,左侧部分都是固定的。
我使用的是 bootstrap v3.1.1 版
<div class="row">
<div class="col-lg-3">
<div class="affix">
fixed position
</div>
</div>
<div class="col-lg-9">
Normal data enter code here
</div>
</div>
重复 Ihab'answer 的回答,只需使用 position:fixed
和引导符 col-offset
,就不需要对宽度做具体规定。
<div class="row">
<div class="col-lg-3" style="position:fixed">
Fixed content
</div>
<div class="col-lg-9 col-lg-offset-3">
Normal scrollable content
</div>
</div>
按照这里的解决方案 [
][1]、<div class="row">
<div class="col-lg-3 fixed">
Fixed content
</div>
<div class="col-lg-9 scrollit">
Normal scrollable content
</div>
</div>
我修改了一些 css,效果非常好:
.fixed {
position: fixed;
width: 25%;
}
.scrollit {
float: left;
width: 71%
}
感谢 @Lowkase 分享解决方案。