Bootstrap grid-layout

拥有回忆 提交于 2019-12-11 10:12:01

问题


I am newbie with bootstrap gridline system so I got stucked when I tried to create that (advanced?) gridview:

So my problem is that I do not know how to organize blocks in rows, because some blocks must have difeerent height, for example height of block 5. should have the same size as blocks 3. and 2. together.

Is that even possible? Also there should be some space between blocks, so background image should fill those space.

Please help me out.


回答1:


What you'll want to do is place divs 2, 3, and 4 in their own container div (with the class .col-md-3) and 5 and 6 in another container div (with the class .col-md-3). Make div 1 have the .col-md-6 class.

Edit: You should use a media query to make it a fixed height in the desktop, then a flexible height when it's mobile.

@media screen and (max-width: 980px) { #div2 { height: 500px; (or whatever)}}



回答2:


I think the most efficient way to do this is to simply use a single row with three columns. Your divs can stack inside the appropriate columns, and you can define the heights for each one. You can see it in action here: http://jsfiddle.net/StSmith/Z9SpM/1/

<div class="container">
  <div class="row">
    <div class="col-lg-6">
      <div id="box1">1</div>
    </div>
    <div class="col-lg-3">
      <div id="box2">2</div>
      <div id="box3">3</div>
      <div id="box4">4</div>
    </div>
    <div class="col-lg-3">
      <div id="box5">5</div>
      <div id="box6">6</div>
    </div>
</div>




回答3:


A simple way to do this is to declare the divs in the order you listed, and then apply a simple float: left. If you define the heights of each div manually it should all fit into place!




回答4:


Rachel's got the right idea. You really just need to nest rows into a container, then use CSS to adjust the heights.



来源:https://stackoverflow.com/questions/23686880/bootstrap-grid-layout

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!