user1072337
user1072337

Reputation: 12945

Responsive rows with Twitter Bootstrap

I have two rows of three columns that I have set up with Twitter Bootstrap like so:

<div class="row">
    <div class="col-md-4">
     Some Stuff
    </div>
    <div class="col-md-4">
     Some more stuff
    </div>
    <div class="col-md-4">
     Even more stuff
    </div>
</div>
<div class="row">
    <div class="col-md-4">
     Some Stuff
    </div>
    <div class="col-md-4">
     Some more stuff
    </div>
    <div class="col-md-4">
     Even more stuff
    </div>
</div>

This works fine for a certain pixel width (two rows of three nice columns), but when I reduce the screen size, it has 2 in one row, and then 1 on another row (for 1 row). And then when an iPhone screen size they are each in their own row, but they are off center.

How do I make it so that these rows are responsive so that, when the screen size is reduced, 2 columns are displayed as 50% of the container width? And then when the screen is reduced to a phone device width, each column takes up 100% of the container width.

Upvotes: 0

Views: 274

Answers (3)

GS Bala
GS Bala

Reputation: 400

Please try this,

<div class="row">
  <div class="col-xs-12 col-sm-6 col-md-4"> Some Stuff </div>
  <div class="col-xs-12 col-sm-6 col-md-4"> Some more stuff </div>
  <div class="col-xs-12 col-sm-6 col-md-4"> Even more stuff </div>
  <div class="col-xs-12 col-sm-6 col-md-4"> Some Stuff </div>
  <div class="col-xs-12 col-sm-6 col-md-4"> Some more stuff </div>
  <div class="col-xs-12 col-sm-6 col-md-4"> Even more stuff </div>
</div>

Upvotes: 2

RKS
RKS

Reputation: 168

use phone size css instead of desktop so it will remain same on all screen sizes.

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row">
    <div class="col-xs-4">
     Some Stuff
    </div>
    <div class="col-xs-4">
     Some more stuff
    </div>
    <div class="col-xs-4">
     Even more stuff
    </div>
</div>
<div class="row">
    <div class="col-xs-4">
     Some Stuff
    </div>
    <div class="col-xs-4">
     Some more stuff
    </div>
    <div class="col-xs-4">
     Even more stuff
    </div>
</div>

Upvotes: 0

Jagdish Parmar
Jagdish Parmar

Reputation: 599

See Example:

<div class="row">
  <div class="col-xs-12 col-sm-6 col-md-4"> Some Stuff </div>
  <div class="col-xs-12 col-sm-6 col-md-4"> Some more stuff </div>
  <div class="col-xs-12 col-sm-6 col-md-4"> Even more stuff </div>
  <div class="col-xs-12 col-sm-6 col-md-4"> Some Stuff </div>
  <div class="col-xs-12 col-sm-6 col-md-4"> Some more stuff </div>
  <div class="col-xs-12 col-sm-6 col-md-4"> Even more stuff </div>
</div>

Upvotes: 5

Related Questions