I am doing a website using bootstrap 3.0 which I want the HTML and CSS to be seen neatly on a desktop, tablet and mobile.
A problem that I am having is that when you view the site on a mobile display the column are stacked (in which I am not criticizing as this stops scrolling as much as possible). However, I would like a little gap between the columns (even 1-2px).
The code so far
<div class="row">
<div class="col-xs-12 col-sm-8 col-md-8">
<div class="Columns">
..content
</div>
</div>
<div class="col-xs-12 col-sm-8 col-md-4">
<div class="Columns">
..content
</div>
</div>
</div>
An image to show what this is doing and to display the stack columns
How could I achieve a little gap between the columns?
Thanks
To add space between columns in Bootstrap use gutter classes. With gutters you can add horizontal or vertical space or even specify how big space should be on different screen size.
The gutters between columns in our predefined grid classes can be removed with . g-0 . This removes the negative margin s from . row and the horizontal padding from all immediate children columns.
Bootstrap 4 has spacing utilities that make adding (or substracting) the space (gutter) between columns easier. Extra CSS isn't necessary. You can adjust margins on the column contents using the margin utils such as ml-0 (margin-left:0), mr-0 (margin-right:0), mx-1 (. 25rem left & right margins), etc...
Bootstrap includes a responsive, mobile first fluid grid system that appropriately scales up to 12 columns as the device or viewport size increases. It includes predefined classes for easy layout options, as well as powerful mixins for generating more semantic layouts.
Add a custom class .column-margin
to set the margin between the rows/columns.
@media (max-width: 991px) {
.column-margin {
margin: 2px 0;
}
}
<div class="row">
<div class="col-xs-12 col-sm-8 col-md-8">
<div class="Columns column-margin">
<img src="http://placehold.it/300x300" />
</div>
</div>
<div class="col-xs-12 col-sm-8 col-md-4">
<div class="Columns">
<img src="http://placehold.it/300x300" />
</div>
</div>
</div>
Codeply
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With