1

I need to create a responsive layout, and I have used bootstrap before but I have never actually attempted this. Making full width designs is plenty easy, but I want a two column layout that would say.. have a max width of 900px together.

The example of what I am trying to do can actually be seen right here on stackoverflow. There are two columns to this site, but both columns are centered on the page right now with space to the left and right. I just need that (and responsive as well for smaller screens).

1
  • 2
    Welcome to Stack Overflow. Good to see you have submitted a quality question, but this site is not a coding service. Please don't ask how to implement something like this. As per proper SO etiquette, you should show what you have tried and ask for assistance in improving your code or filling in the gaps. We will happily try to help you fix up your code though :) Commented Sep 15, 2013 at 23:52

2 Answers 2

1

Assuming your container has an id of container you can center it by giving auto left and right margin like:

#container { 
   margin: 0 auto;
}

The width of a default bootstrap grid is 960px and is already centered by default. You only have to assign a class called container like

<div class="container">
     <!-- The begin your row -->
     <div class="row">
          <div class="span8">
               Demo right part of stackoverflow
          </div>
          <div class="span4">
               Demo left part of stackoverflow         
          </div>
     </div>
</div>
Sign up to request clarification or add additional context in comments.

1 Comment

thank you this helped, but why doesn't it center automatically as said by @Alax Menon ?
0

If you create your layout using Bootstrap grid system it will automatically align the container div to horizontally center, there is no need to any thing. Just follow this code:

<div class="container">
     <div class="row">
          <div class="span8">
               <!-- left column -->
          </div>
          <div class="span4">
               <!-- right column -->        
          </div>
     </div>
</div>

Further you can check out this page to know how Bootstrap grids works - http://www.tutorialrepublic.com/twitter-bootstrap-tutorial/bootstrap-grid-system.php

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.