Bootstrap   发布时间:2022-04-18  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了bootstrap-4 – Bootstrap 4:如何在响应网格中制作固定列?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
使用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

大佬总结

以上是大佬教程为你收集整理的bootstrap-4 – Bootstrap 4:如何在响应网格中制作固定列?全部内容,希望文章能够帮你解决bootstrap-4 – Bootstrap 4:如何在响应网格中制作固定列?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。