"Enhance your design with stylish vertical spacing in Bootstrap 4 columns

My goal is quite simple - I just want to create a small gap of 10 pixels between each column item in a row. It seems like something as basic as this should be included in Bootstrap, but I can't seem to locate it in the documentation.

Every time I search for a solution, all I find are messy hacks involving extra divs and classes.

Is there an elegant or built-in method to achieve such a straightforward design?

HTML

<div class="container">
  <div class="row">
    <div class="col-md-2 content">
      1 of 2
    </div>
    <div class="col-md-10 content">
      2 of 2
    </div>
  </div>
</div>

CSS

.row {
  background: #f8f9fa;
  margin-top: 20px;
}

.col {
  border: solid 1px #6c757d;
  padding: 10px;
}

.content{
  background-color: #ffffff;
  padding: 20px;
  border-radius: 5px;
  background-clip: padding-box;
  margin-bottom: 20px;
  box-shadow: 0 0 2px 0 rgba(0, 0, 0, 0.06);
 }

Codpen: https://codepen.io/anon/pen/vjPYJy

Answer №1

Consider redesigning your HTML structure and incorporating bootstrap spacing classes:

<div class="col-md-2 p-0">
  <div class="content mr-2">
     1 of 2
  </div>
</div>
<div class="col-md-10 p-0">
  <div class="content ml-2">
     2 of 2
  </div>
</div>

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

Implementing gridlines on a webpage using HTML and JavaScript to mimic the grid layout found in Visual Studios

Currently, I have a grid snap function in place, however, I am looking to add light grey lines horizontally and vertically on my Designing application. The goal is to achieve a similar aesthetic to Visual Studios' form designing feature. Utilizing so ...

Troubleshooting: Difficulty with svg mask function when implementing an svg image in a react.js environment

I'm attempting to achieve an effect where an image appears above a background image when hovering over it, similar to this example... https://jsfiddle.net/12zqhqod/7/ <img id="heretic" height="300px" width="300px" src="http://i.imgur.com/0bKGVYB ...

How can I make a long text in Bootstrap 4.1 go under the second column instead of the first column

Is it possible for text to flow under the second column? There is some free space under it and I want the text to expand to 100% width of the screen when possible. I have set the height of the second column using 'height: fit-content', so there i ...

Footer displays within the content section

Currently, I am utilizing Next.js and antd's layout components to create a dashboard-style page using their Layout component. However, I have encountered two issues related to styling (CSS) in this setup: Footer appearing within the Content: I am wo ...

Pressing the button will not have any effect unless the textarea is unfocused

I am having an issue with my HTML textarea that expands on focus. Below the textarea, I have a button for users to submit their input. However, when the textarea is expanded and the button is clicked, it does not fire the onclick event. Instead, it causes ...

Combining various arbitrary values, like :has in Tailwind, can be achieved by following these steps

I'm facing an issue where I need to hide an element if it has children. In regular CSS, this is achieved with the following code: &:not(:has(*)){ display: none } However, when trying to implement this in Tailwind, I'm struggling to figure ...

Integrating Images Seamlessly with Text using HTML and CSS

Still getting the hang of this! I'm working on a webpage with an image and text side by side in separate divs. I've positioned them correctly, but when I resize the page, the text changes size while the image stays the same. I want the text to al ...

Arrange radio buttons vertically in a table

I am attempting to display a vertical list of radio buttons within a table cell. Is this achievable? Here is the code snippet I am currently working with: <table> <tr> <td> First Name </td> ...

The links located beneath the iframe/span element are unclickable

My latest creation is a static advert ticker positioned at the bottom of the window. It's contained within an <iframe> for easy placement on other websites. I added a <span> around the <iframe> to keep it fixed at the bottom of the s ...

Unusual shift in the modal's behavior occurs when the parent component's style.transform is applied

I have encountered an unusual issue with a modal's appearance and functionality. The modal is designed to enlarge images sent in a chat, with the chat upload preview div serving as the parent element and the modal as the child element. This strange be ...

The tab-width property in CSS allows you to specify the

Are there methods in WebKit and Microsoft browsers to specify tab width as in Firefox and Opera with -moz-tab-size and -o-tab-size properties? For instance, I would like the tabs in my <textarea> to be 4 spaces wide: textarea { -moz-tab-size: 4 ...

Is there a way to incorporate HTML input text into an image with CSS?

Here is an image that I have: https://i.sstatic.net/wHNk1.png Is there a way to add input fields to this image? I want the user to be able to click on the input fields (green boxes) within the image and enter values. How can I achieve this? ...

Navigating Divs Using jQuery

I am working with a class that has multiple divs, each with a unique id attached to it. I am using jQuery to dynamically cycle through these divs. This is a snippet of my HTML code: <div id ="result">RESULT GOES HERE</div> ...

The navigation tabs in Bootstrap are not functioning properly and are failing to show the corresponding content. Is anyone else facing this issue with Electron.js

I'm having trouble understanding why The tabs aren't changing when clicked The tabs aren't showing any content I'm working with electron and bootstrap, so I'd really appreciate any recommendations or solutions. I've looked ...

Navbar transition issue in Bootstrap

Having trouble with Bootstrap transitions not functioning correctly on my navbar. The issue is when I click the dropdown button in the navbar, the hidden elements appear abruptly without any transition effect. Below is the HTML code being used: <!do ...

Creating a PHP form modal with Bootstrap 3 and validation functionality

I am experimenting with the Bootstrap 3 modal feature and have created a basic form within the modal. My objective is to process the form using PHP, which I have achieved with the following script: $(function() { $("button#submit").click(function() { ...

Tips on concealing an element using CSS based on its specific title

I have a specific input element that I need to hide, along with a few others. Is there a way to do this using their names? <input type="image" alt="Storage Administration" src="App_Themes/Default/topmenu$store$png$ffffff$000000.IconHandler.axd" title=" ...

Transforming the appearance of a Formik Multi-Select component to resemble a Material-UI select widget

I need help styling the Formik select component for multiple selections. I want to make it look like a Material-UI select with some specific height, length, and rounded borders. Any advice on how to do this using Material-UI styling or my own custom stylin ...

Exploring how to set dropdown menu width for Angular2 mat-select options

Currently, I am using the angular2 mat-select control and facing an issue with the width and position of its dropdown list menu. By default, it is wider and overflows the element on both sides by a few pixels. I have not found any option for adjusting the ...

What causes the <td> element to extend beyond the boundaries of the <table>?

I need to add next and previous buttons to a <td> that has an asp:DropDownList. However, when I do this, the <td> ends up overflowing the width of the table. Here is the edited code snippet with the entire table included: <table class=" ...