I'm using Twitter Bootstrap 3.0 LESS source in my Asp.Net MVC 5 project. I use a Top Navbar (as given here) and then few more rows in the the layout page.
I use following for rows to take 100% page width:
<div class="row">
<div class="col-md-12">
// More HTML code
</div>
</div>
But this adds an extra padding on the right of each row. This also adds a horizontal scrollbar to the page and a blank vertical gutter throughout the page is visible when scrolled the page to its right.
Removing margin-right on each row and padding-right on all col-md-12 corrects the layout. However, I don't feel this is the correct way to do it.
Any idea how to remove those unnecessary margin and padding on right once for all, throughout the resultant bootstrap.css?
You would have to go into bootstraps source code, find the
.row
selector, and change the css associated with.This is probably not what you want to do.
Instead, I would recommend creating your own selector to use for this type of row you want. If you were to do this though, you couldn't call it
.row
because it would conflict with.row
selector used by bootstrap. You'd have to call it something like.custom-row
Your problem is caused by NOT wrapping your
.row
s in a.container
class.Try this:
The
width:100%;
on your.container
will make the rows 100% (red). The will still be a padding around your content (yellow). This padding is the gutter of the grid, see: https://stackoverflow.com/a/19044326/1596547All
col-*-*
have a padding of 15px on both sides. There is no difference between the*-12
classes except from the*-12
classes don't have a float left.css / less selector for all your
col-*
classes:css / less selector for all your
col-*-12
classes:The easiest way to solve this problem is to comment out left and right padding from all columns, set left and right padding on container class to 0 and to remove a negative margin from rows.
Just comment out .row class at line 691 and at line 714 comment out code for left and right padding on class^="col-".
That's works for me:
As mentioned above the first thing to do is have matching container and row classes:
To remove that padding, you could then use some css like so:
I added a class tight to the container to restrict this padding removal to just this one spot (or any other container with tight on it). Doing it globally could interfere with other things like navbars potentially.
The original bootstrap code is
that's why you have padding and a scroll bar.
So you want to reset them at
0px
but if it's something you only want once, you should not override the original bootstrap CSS. Then you can later use it with the normal behavior.What I would do is to add another class like this:
Then with this CSS
that way, you can use
.row
with the normal behavior after.You can resolve this issue in Bootstrap 3 by:
Example:
First wrap your row in a container:
Then add a padding of 0px to your container class:
Finish off by hiding the horizontal overflow:
Ta da!