加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

bootstrap-4 – Bootstrap 4:如何在响应网格中制作固定列?

发布时间:2020-12-18 00:28:50 所属栏目:安全 来源:网络整理
导读:使用bootstrap,是否可以为某些断点保持网格列固定? 并且为同一列堆叠并与其他断点的页面一起流动? 在下面的示例中,对于大屏幕,我希望右列中的内容在左列保持固定时滚动.对于小屏幕,左列应叠加在右侧,页面应正常滚动. div class="container-fluid" div clas
使用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

解决方法

偏移未修复的列:
<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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读