Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Boostrap 3 - col-md-4 to col-sm-6, or grid of 3x2 to 2x3

How can I change a grid of 3x2 to 2x3 without having an empty space where one row ends and another starts?

For example:

 <div class="row"> 
     <div class="col-md-4 col-sm-6">
        content
    </div>
    <div class="col-md-4 col-sm-6">
        content
    </div>
    <div class="col-md-4 col-sm-6">
        content
    </div>
</div>
<div class="row"> 
    <div class="col-md-4 col-sm-6">
        content
    </div>
    <div class="col-md-4 col-sm-6">
        content
    </div>
    <div class="col-md-4 col-sm-6">
        content
    </div>
</div>

This is what I want to achieve:

This: enter image description here

To this: enter image description here

But instead I get this:enter image description here

like image 787
MP_Webby Avatar asked Dec 14 '22 14:12

MP_Webby


2 Answers

Just put it all in one row - it'll wrap down automatically.

 <div class="row"> 
     <div class="col-md-4 col-sm-6">
        content 1
    </div>
    <div class="col-md-4 col-sm-6">
        content 2
    </div>
    <div class="col-md-4 col-sm-6">
        content 3
    </div>
    <div class="col-md-4 col-sm-6">
        content 4
    </div>
    <div class="col-md-4 col-sm-6">
        content 5
    </div>
    <div class="col-md-4 col-sm-6">
        content 6
    </div>
</div>

JSFiddle

like image 95
enigma Avatar answered Dec 22 '22 00:12

enigma


Put them all in one row. See this bootply

Like:

<div class="row"> 
     <div class="col-md-4 col-sm-6">
        <span class="box">content</span>
    </div>
    <div class="col-md-4 col-sm-6">
      <span class="box">content</span>
    </div>
    <div class="col-md-4 col-sm-6">
        <span class="box">content</span>
    </div>

    <div class="col-md-4 col-sm-6">
        <span class="box">content</span>
    </div>
    <div class="col-md-4 col-sm-6">
        <span class="box">content</span>
    </div>
    <div class="col-md-4 col-sm-6">
        <span class="box">content</span>
    </div>
</div>
like image 28
Ted Avatar answered Dec 21 '22 23:12

Ted