Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
483 views
in Technique[技术] by (71.8m points)

Bootstrap Fluid grid system with different height

I am new in Bootstrap. I want to use the fluid grid system grid with different height and same width like the following image Bootstrap grid image.

How can i implement the same? Please help me.

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The only way to do this with Bootstrap "out-of-the-box" would be to use 4 columns and stack the items in each. This isn't ideal for dynamic content when you don't know how many items you'll have in each column. Also the items order top-to-bottom, and not left-to-right.

<div class="container-fluid">
    <div class="row">
        <div class="col-md-3">
        <!--item1-->
        <!--item2-->
        <!--item3-->
        <!--item4-->
        </div>
        <div class="col-md-3">
        <!--item5-->
        <!--item6-->
        <!--item7-->
        <!--item8-->
        </div>
        <div class="col-md-3">
        <!--item-->
        <!--item-->
        <!--item-->
        </div>
        <div class="col-md-3">
        <!--item-->
        <!--item-->
        <!--item-->
        <!--item-->
        <!--item-->
        </div>
      </div>
</div>


Otherwise, you have to use a jQuery plugin like Masonry or Isotope, or using CSS3 multi-columns.

Jquery plugin method

Bootstrap Masonry Demo
Bootstrap Masonry Demo 2

CSS3 columns method (Masonry-like CSS solution)..

This is not native to Bootstrap 3, but another approach using CSS multi-columns. One downside to this approach is the column order is top-to-bottom instead of left-to-right.

CSS3 multi-columns Demo

There is also more detailed info in this answer to a similar question.

Update 2018

Bootstrap 4 includes a Masonry-like solution using CSS3 multi-columns: Masonry cards Demo


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...