Is it feasible to incorporate gutters in columns using Bootstrap 4?

No matter how hard I search online, I can't seem to find a clear answer about adding gutters to columns in Bootstrap 4. All the articles I come across talk about adding gutters in Bootstrap 3 or even removing them in Bootstrap 4. Is it possible to add equal gutters without causing columns to break and wrap? If so, how can this be achieved without affecting flexbox?

I have created a demonstration of the grid I'm working on in this JsFiddle. Any guidance or direction would be greatly appreciated.

.sec-accent {
  background-color: #fafcf5;
}

.blue {
  background-color: #9999cc;
}
<div class="container">
    <div class="row">
      <div class="col-sm-12 blue" style="height:500px;">
        Hello World
      </div>
    </div>

    <div class="row">
      <div class="col-sm-4 blue" style="height:500px;">
        Hello World
      </div>
      <div class="col-sm-8 blue" style="height:500px;">
        Hello World
      </div>
    </div>

    <div class="row">
      <div class="col-sm-4 blue" style="height:500px;">
        Hello World
      </div>
      <div class="col-sm-4 blue" style="height:500px;">
        Hello World
      </div>
      <div class="col-sm-4 blue" style="height:500px;">
        Hello World
      </div>
    </div>

    <div class="row">
      <div class="col-sm-6 blue" style="height:500px;">
        Hello World
      </div>
      <div class="col-sm-6 blue" style="height:500px;">
        Hello World
      </div>
    </div>

    <div class="row">
      <div class="col-sm-12 blue" style="height:500px;">
        Hello World
      </div>
    </div>
  </div>

EDIT: 9 April 2018

After some more research and understanding Bootstrap gutters better, I was able to find a solution to my problem. You can check out the updated version in this JsFiddle.

Thank you for all the help received.

Kind regards, -B.

Answer №1

It appears there may be some confusion regarding the gutters in Bootstrap 3 and 4. Both versions already include 30px gutters between columns by default. The issue in your code seems to be that you have applied the .blue class directly within the divs containing the col-* classes. Instead, it is recommended to apply the .blue class outside of these divs. You can try adjusting your code as shown below.

<div class="container">
    <div class="row">
        <div class="col-sm-12">
            <div class="blue" style="height:500px;">
                Hello World
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-sm-4">
            <div class="blue" style="height:500px;">
                Hello World
            </div>
        </div>
        <div class="col-sm-8">
            <div class="blue" style="height:500px;">
                Hello World
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-sm-4">
            <div class="blue" style="height:500px;">
                Hello World
            </div>
        </div>
        <div class="col-sm-4">
            <div class="blue" style="height:500px;">
                Hello World
            </div>
        </div>
        <div class="col-sm-4">
            <div class="blue" style="height:500px;">
                Hello World
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-sm-6">
            <div class="blue" style="height:500px;">
                Hello World
            </div>
        </div>
        <div class="col-sm-6">
            <div class="blue" style="height:500px;">
                Hello World
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-sm-12">
            <div class="blue" style="height:500px;">
                Hello World
            </div>
        </div>
    </div>
</div>

Answer №2

After some experimentation, I stumbled upon a solution that fits my needs perfectly.

<div class="column-4 background-primary border border-white"></div>

The use of "border border-white" may not physically create space between columns, but it can provide the illusion of separation when paired with a background color.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Scrolling horizontally with Bootstrap 4

I'm having trouble with this issue: I need my "Factuur" (Dutch for invoice) to always be at a width of 800px, but on mobile devices, the rows are collapsing into each other. I want the invoice to remain static and be scrollable. Below is my CSS code: ...

The reason behind ubuntu's Ambiance GTK3 theme incorporating CSS in its settings.ini file

Exploring the functionality of theming in GTK3 using CSS, I decided to experiment with my default theme in Ubuntu 13.04, known as Ambiance. The source for this theme can be found at /usr/share/themes/Ambiance/gtk-3.0/. Interestingly, when attempting to mo ...

Verify the validity of CSS code using C#

Seeking out a function within the vast .Net-Framework that can assist in validating CSS-syntax across various versions, such as CSS 3.0 and 2.0. It would be ideal if it includes a CSS parser with validation capabilities built-in. Any recommendations for ...

Angular 7 - Issue with Loading Material Component Styles

In the midst of my latest Angular 7 project, I decided to incorporate the out-of-the-box material components. Unfortunately, there seems to be a hiccup with some of the CSS not being applied and pinpointing the cause is proving to be an elusive task. For ...

two adjacent elements filling the entire height of the window at 100% dimensions

Is there a way to place two elements side by side, with one of them (the textarea) always being 100% height of the window? I've looked at similar questions here but can't figure out how to make it work. Can you help me with this? html: <div ...

What's preventing vh from functioning in Chrome, yet it's fully operational in Internet Explorer?

Currently, I am utilizing vh for my project, which as far as I know represents 1 percent of the view height of the page. This measurement should function similar to percentages, especially with borders and potentially other elements. However, when I tested ...

Issue with CSS Transform Causing Rendering Errors in Both Chrome and Firefox

While a pixel here or there can be overlooked, in this case, precision is essential for the perfect rendering of this simple menu. The spacing between menu items must be impeccably equal to avoid any merging or disjointed appearance. Currently, the sep ...

What is the best way to vertically center my footer text?

footer { text-align: center; color: #FFF; position: fixed; bottom: 0px; width: 100%; height: 90px; background-color: #464646; } <footer> &copy; Name </footer> I am looking to center my name within the footer, however, it cu ...

Is it possible to apply styles to the options in a grouped_collection_select in Rails?

I am currently utilizing Twitter Bootstrap and Ruby on Rails as the backend for my project. Despite extensive research, I have been unable to find a solution to my current issue. Within my web application, I am looking to implement dependent dropdowns (s ...

Escape from an iframe with the help of a buster

My website is being targeted by a code that prevents it from breaking out of an iframe. Despite trying different frame breaker scripts, I have not been successful in resolving this issue. Any assistance would be greatly appreciated. Thanks! Buster: func ...

Integrate automatic column spacing in Bootstrap grid system

Is there a way to automatically add spacing between Bootstrap columns? For example, if I have a column with a width of 5 and another with a width of 4, the offset should be 3. How can this be achieved? ...

Effective method for centering a navigation bar vertically within a section element without relying on absolute positioning

Let's explore a unique way to vertically center content within a div while steering away from fixed values. Interestingly, the typical solutions don't always work as expected in a section environment. The challenge now is: How can we center the ...

On desktop browsers, the position is set to fixed, while on mobile devices such as Android and iOS, it is set

The other day, I encountered an unexpected problem with fixed positioning. After some searching, I came across a few articles on the topic (one of which is ) and it seems that there is no clear solution available. In short, I am looking to have a fixed na ...

CSS technique for arranging text in order?

My website has a unique layout where certain text appears differently on desktop and mobile devices. Specifically, I have a simple text that looks like this on desktop: Kolor : Niebieski Rozmiar : S/M However, I want it to appear like this on mobile: Ko ...

When incorporating CSS with Bootstrap, it may not always have a visible impact on the

As a newcomer to using Bootstrap, I recently created a webpage with Bootstrap3. However, I encountered an issue when trying to apply two classes to the same element, as the CSS was not being applied: Here is the HTML code snippet: <div class="col-md-4 ...

The issue of Django/Python static files not loading is causing disruption

mysite/settings.py """ Configuration settings for the Django project called mysite. This file was generated by 'django-admin startproject' using Django 1.9.5. For more details about this file, visit https://docs.djangoproject.com/en/1.9/topics ...

How can I convert an HTML Div to CSS styling?

Currently, I am attempting to transform the following HTML code snippet into CSS. While I understand that you can utilize div in CSS, I am uncertain if it is possible to use an href with CSS. Here is the code in question: <div id="menubar1"> <a ...

Tips for incorporating inline images with gatsby-image

Seeking Solution In my quest to query and showcase images with a maximum width of 350px, I am hoping to have them displayed inline-block for tablets and larger screens. Ideally, each image would sit next to one another and wrap if they exceed the parent d ...

Developing a jQuery plugin

I successfully developed a slider component using jQuery and now I'm interested in transforming it into a plugin for reusability across multiple projects. However, I encountered some challenges when working with multiple instances of the slider withi ...

Creating a website with a responsive design that perfectly adapts to different screen sizes, starting with my 1920x1080

've been working on designing a website using Dreamweaver CS6, and during this process, I encountered some challenges. Initially, I set everything up based on hard pixel values for div and image sizes, but realized that this caused severe breaks in th ...