Problem:
Remove padding/margin to the right and left of col-md-* in Bootstrap 3.
HTML code:
<div class="col-md-12">
<h2>OntoExplorer<span style="color:#b92429">.</span></h2>
<div class="col-md-4">
<div class="widget">
<div class="widget-header">
<h3>Dimensions</h3>
</div>
<div class="widget-content" id="">
<div id='jqxWidget'>
<div style="clear:both;margin-bottom:20px;" id="listBoxA"></div>
<div style="clear:both;" id="listBoxB"></div>
</div>
</div>
</div>
</div>
<div class="col-md-8">
<div class="widget">
<div class="widget-header">
<h3>Results</h3>
</div>
<div class="widget-content">
<div id="map_canvas" style="height: 362px;"></div>
</div>
</div>
</div>
</div>
Desired output:
Currently this code adds padding/margin to the right and left of the two columns. I am wondering what it is I am missing in order to remove this extra space on the sides?
Notice:
If I remove "col-md-4" then both columns expand to 100% but I want them to be next to each other.
I guess it's easier to just use
to override the original value set by bootstrap.
I've tried
and it worked for me.
Remove spacing from b/w columns using bootstrap 3.7.7 or less.
Bootstrap 4 has a native class to do this : add the class
.no-gutters
to the parent.row
Another solution, feasible only if you compile bootstrap from its LESS sources, is to redefine the variable which sets the padding for the columns.
You will find the variable in the
variables.less
file: it's called@grid-gutter-width
.It's described like this in the sources:
Set this to 0, compile
bootstrap.less
, and include the resultingbootstrap.css
. You are done. It can be an alternative to defining an additional rule, if you are already using bootstrap sources like I am.You'd normally use
.row
to wrap two columns, not.col-md-12
- that's a column encasing another column. Afterall,.row
doesn't have the extra margins and padding that acol-md-12
would bring and also discounts the space that a column would introduce with negative left & right margins.if you really wanted to remove the padding/margins, add a class to filter out the margins/paddings for each child column.