skip to Main Content

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.

3

Answers


  1. 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>
    
    Login or Signup to reply.
  2. 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>
    Login or Signup to reply.
  3. 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>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search