Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change the default Twitter Bootstrap margin 20px for span classes

I use

<div id="windows">
    <div class="row-fluid">
        <div class="span4 mywindow">Text</div>
        <div class="span4 mywindow">Text</div>
        <div class="span4 mywindow">Text</div>
    </div>
</div>

within a div #windows of a special width.

I want to reduce the default 20px space between these three blocks.

these css code

#windows .span4
{
    margin-right:-10px;
}

sets up a proper space between blocks, but each block keep the same width so the total width is less than 100% of the parent div (there is a right space).

I can fix it by changing the width of the blocks using !important. So the fix is

#windows .span4
{
margin-right:-10px;
width:180px !important;
}

The question then is: does it make sense to use Twitter Bootstrap span4 class for my windows if I have to fix it so hard?

I mean, is it a good practice to fix both margin-right and width for Twitter Bootstrap span classes or there is a simplier and a better solution to fix blocks? P.S. Twitter Bootstrap is used for another purposes on the page as well (so span4 is not the only reason to use Twitter Bootstrap in my case).

like image 565
Haradzieniec Avatar asked Aug 01 '12 09:08

Haradzieniec


People also ask

What is default margin in bootstrap?

4 - (by default) sets the margin or padding to $spacer* 1.5 i.e. 1.5 rem or 24px. 5 - (by default) sets the margin or padding to $spacer* 3 i.e. 3rem or 48px. auto - for classes that set the margin to auto.

Which class will you use to set margin auto to the right side in bootstrap 5?

e - (end) for classes that set margin-right or padding-right in LTR, margin-left or padding-left in RTL. x - for classes that set both *-left and *-right. y - for classes that set both *-top and *-bottom. blank - for classes that set a margin or padding on all 4 sides of the element.

What is $spacer in bootstrap?

$spacer is a SASS variable. By default it's value is 1rem . Therefore mt-1 is margin-top:. 25rem; The value for each of the 6 spacing units (0-5) are derived from the $spacers SASS map variable...


1 Answers

You are triyng to change gutter width between the columns. The easiest way to do this is to customize BS build before the download:

http://twitter.github.com/bootstrap/customize.html#variables

Change @gridGutterWidth value there (for fixed layout), then download your build.

like image 167
Pavlo Avatar answered Nov 13 '22 04:11

Pavlo