Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Twitter bootstrap: how to add side margins?

I have a page with centered Twitter Bootstrap container .

This container has a header that spans the entire width (span12) and below the header is a gallery of pictures, which is a bunch of rows with 4 cells (containing pictures) in each row.

I would like to add side margins to each row so that the first and last picture are not completely snug with container borders and pictures are spaced equally. I don't want to use offset1 for the margin because it is way too big.

Here is a link to the current mockup: http://i46.tinypic.com/21e2h4o.jpg

like image 731
alecswan Avatar asked Jun 22 '12 23:06

alecswan


People also ask

How do I create a side margin in Bootstrap?

l - sets margin-left or padding-left. 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.

How do you put a margin on a class in Bootstrap?

l - for classes that set margin-left or padding-left. r - for classes that set margin-right or padding-right. x - for classes that set both *-left and *-right. y - for classes that set both *-top and *-bottom.

How do you space a line in Bootstrap?

l : margin-left/padding-left. r : margin-right/padding-right. x : for padding-left and padding-right/margin-left and margin-right. y : for padding-top and padding-bottom/margin-top and margin-bottom.


1 Answers

You can use the nth-child css property

nth-child(4n+1) for the left margin

nth-child(4n+4) for the right margin

http://css-tricks.com/how-nth-child-works/

Or

add a <div> in your .span12 with style="padding:0 19px"

and add inside a <div class="row-fluid">

<div class="row">
  <div class="span12">
    <div style="padding:0 19px">
      <div class="row-fluid">
        <div class="span3">3</div>
        <div class="span3">3</div>
        <div class="span3">3</div>
        <div class="span3">3</div>
      </div>
    </div>
  </div>
</div>

like image 136
baptme Avatar answered Oct 10 '22 19:10

baptme