Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap: Gap between columns on mobile display

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

enter image description here

How could I achieve a little gap between the columns?

Thanks

like image 632
user3428422 Avatar asked May 24 '15 13:05

user3428422


People also ask

How do I gap between columns in Bootstrap?

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.

How do I remove spaces between Bootstrap columns?

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.

How do I add a space between columns in Bootstrap 4?

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...

Is Bootstrap responsive to mobile?

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.


1 Answers

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

like image 140
m4n0 Avatar answered Oct 13 '22 01:10

m4n0