Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to increase padding between columns using Bootstrap 3.0

I am relatively new to programming and am making a website using bootstrap 3.0.

I want to make two rows that center in the middle of the page. For the first row I used div class="col-md-4 col-md-offset-2" and for the second row div class="col-md-4".

My first question is if it is ok that this adds up to 10 rows instead of 12 or if I need to specify the 2 rows on the right also? If so, how can this be done?

Also I would like to increase the horizontal spacing between the columns. I did a bit of research on that and came across mixins but its quit hard for me to grasp. If anybody here can provide me with a simple way to increase the horizontal spacing between two columns that would be great.

Thanks in advance.

like image 420
Stiño Avatar asked Jul 01 '14 12:07

Stiño


People also ask

How can I increase the space between two columns in Bootstrap?

To add space between columns in Bootstrap use gutter classes. With gutters you can add horizontal or vertical space or even specify how big space should be on different screen size.

How do you put a space between four columns in Bootstrap?

Using “div” tag: Simply adding a “div” with padding in between two “div” tags gives spacing between the “div”.

How do I give a padding margin in Bootstrap?

r - sets margin-right or padding-right. x - sets both padding-left and padding-right or margin-left and margin-right. y - sets both padding-top and padding-bottom or margin-top and margin-bottom. blank - sets a margin or padding on all 4 sides of the element.


2 Answers

looks like this is what you want

<div class="container">
  <div class="row">
     <div class="col-md-4 col-md-offset-2">col-md-4-offset</div>   
      <div class="col-md-4">col-md-4</div>
   </div>
 </div>

its perfectly fine to have column not add up to 12

here is a bootply

and if you want to pad your rows just add padding to .row class, by default there is no padding or margins between rows

like image 154
nolawi Avatar answered Sep 18 '22 23:09

nolawi


Question 1: Yes, it's fine to leave dangling space after your columns, but good practice to tie it off by closing the .row after it.

Question 2: You can add margin to left and right of the column. But that throws off the offset column, so get around that by putting an empty .col-md-2 before them.

<div class="container">
  <div class="row">
   <div class="col-md-2"></div><!-- empty -->
    <div class="col-md-4 margin">col-md-4</div>
    <div class="col-md-4 margin">col-md-4</div>
  </div>
</div>

CSS:

.margin {
  margin-left:10px;
  margin-right:10px;
  }

Demo: http://www.bootply.com/OS6FX9sie8#

Also, you'll notice in my demo I put the custom class in a media-query. Do that if you want that margin adjustment to only apply on large screen devices, so the columns reach the screen edge on phones.

like image 35
Shawn Taylor Avatar answered Sep 21 '22 23:09

Shawn Taylor