Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap: Class for margin-right?

I believe to provide standard margin-left we can use class "Offset" in bootstrap. At the same time what is the class that can be used to provide standard margin-right? example:

<div class="row-fluid">
    <div class="offset2 span8"></div>
</div>

for some reason I need to give margin-right equivalent to offset2. Some solution will be of great help. Thank you.

like image 236
Prem Ananth C Avatar asked Aug 11 '13 09:08

Prem Ananth C


People also ask

How do I set margin-right 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.

What is the class for margin in bootstrap?

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

Which bootstrap class will you use to get 100% width of a div?

container-fluid class provides a full-width container which spans the entire width of the viewport.

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

There is no equivalent class to offset-x for margin-right and for good reason, it is not needed. Think of it this way, if you need a 6 column div that is offset both right and left 3 columns, you would use:

<div class="row">
    <div class="span6 offset3">Your content...</div>
</div>

Also, if you have a 6 column div that needs to only be offset 2 columns BUT, the offset should be 2 columns on the right, the code would be:

<div class="row">
    <div class="span6 offset4">Your content...</div>
</div>

Keep in mind you are always working in 12 columns (unless changes in variables.less) so you can use span-x AND offset-x to achieve position desired. If you are looking to tweak additional pixels, add an additional class(or ID) to your content container inside of your span. For example:

<div class="row">
    <div class="span6 offset4">
        <div class="tweaked-margin">Your content...</div>
    </div>
</div>

The CSS:

.tweaked-margin {
    margin-right: 4px; // or whatever you need
}
like image 154
Joe Conlin Avatar answered Oct 11 '22 08:10

Joe Conlin