【问题标题】:How to make a fixed column in a responsive grid?如何在响应式网格中制作固定列?
【发布时间】:2019-01-04 04:07:02
【问题描述】:

使用 Bootstrap,是否可以为某些断点保持网格列固定? 并为同一列堆叠和流动与其他断点的页面?

在下面的示例中,对于大屏幕,我希望右列中的内容在左列保持固定时滚动。对于小屏幕,左列应堆叠在右列上,页面应正常滚动。

<div class="container-fluid">
  <div class="row">
    <div class="col-lg-2">
      I want this to always be visible as the right side scrolls.
    </div>
    <div class="col">
    ...
    </div>
  </div>
</div>

CodePen sample

【问题讨论】:

标签: html css bootstrap-4


【解决方案1】:

偏移不固定的列:

<div class="container-fluid">
  <div class="row">
    <div class="col-lg-2">
      I want this to always be visible as the right side scrolls.
    </div>
    <div class="col offset-lg-2">
    ...
    </div>
  </div>
</div>

并应用媒体查询来修复相关断点的另一列:

https://getbootstrap.com/docs/4.0/layout/grid/#grid-options https://getbootstrap.com/docs/4.0/layout/grid/#mixins

@include media-breakpoint-up('lg') {
    #left {
        position: fixed;
        top: 0;
        bottom: 0;
    }
}

Codepen sample

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-10-17
    • 2020-07-25
    • 1970-01-01
    • 2016-12-23
    • 2013-04-18
    • 2023-02-22
    • 1970-01-01
    • 2015-04-15
    相关资源
    最近更新 更多