By default the columns have a gutter separating them. However, by applying a background-color
to the column this won't be obvious because the gutters are created using padding
and the background-color
will extend into the gutter.
One way to see this is by setting the background-color
on a inner element within the column. Like this:
.cat {
height: 100px;
}
.cat-inner {
height: 100%;
padding: 10px;
background-color: #666;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet"/>
<section class="categories">
<div class="container-fluid">
<div class="row mt-1">
<div class="col-12 cat">
<div class="cat-inner">
<h4>Stars and & Planets</h4>
</div>
</div>
</div>
<div class="row mt-1">
<div class="col-8 cat">
<div class="cat-inner">
<h4>Space Travel</h4>
</div>
</div>
<div class="col-4 cat">
<div class="cat-inner">
<h4>Worm Holes</h4>
</div>
</div>
</div>
</div>
</section>
This setup might also solve your problem, as each column now has a visual break between them.
The gutter width can be changed with some simple CSS to reduce the space between the columns. The change will vary depending on how you're using Bootstrap - Sass/Less, CSS, etc. For some simple CSS you can use:
[class*="col-"] {
padding-left: 5px;
padding-right: 5px;
}
This somewhat odd CSS selector will match all elements which contain col-
in their class attribute. ie col-8
, col-12
, col-md-8
, etc. And result in:
NOTE: the example below uses !important
but this is not necessary in most cases. Due to the way SO loads the Bootstrap CSS the !important
is required in this example.
.cat {
height: 100px;
}
[class*="col-"] {
padding-left: 5px !important;
padding-right: 5px !important;
}
.cat-inner {
height: 100%;
padding: 10px;
background-color: #666;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet"/>
<section class="categories">
<div class="container-fluid">
<div class="row mt-1">
<div class="col-12 cat">
<div class="cat-inner">
<h4>Stars and & Planets</h4>
</div>
</div>
</div>
<div class="row mt-1">
<div class="col-8 cat">
<div class="cat-inner">
<h4>Space Travel</h4>
</div>
</div>
<div class="col-4 cat">
<div class="cat-inner">
<h4>Worm Holes</h4>
</div>
</div>
</div>
</div>
</section>