What is the best way to construct the following layout with columns in Bootstrap?

My approach involved dividing the content into two equal columns using col-md-6. Each of these was further split into 3 columns using col-md-4. However, I faced an issue regarding achieving consistent spacing between columns on the right side.

https://i.sstatic.net/94YIj.png

Here is my code snippet:

<div class="container">
    <div class="row">
        <div class="col-md-6">
            <div class="col-md-4 text-center">
                <p>My Earning</p>
            </div>
            <div class="col-md-4 text-center">
                <h5>100</h5>
                <p>Number of Notes Sold</p>
            </div>
            <div class="col-md-4 text-center">
                <h5>$10,000</h5>
                <p>Money Earned</p>
            </div>
        </div>

        <div class="col-md-6">
            <div class="col-md-4 ">
                <h5>38</h5>
                <p>My Downloads</p>
            </div>
            <div class="col-md-4">
                <h5>12</h5>
                <p>My Rejected Notes</p>
            </div>
            <div class="col-md-4 data">
                <h5>102</h5>
                <p>Buyer Requests</p>
            </div>
        </div>
    </div>
</div>

Answer №1

After reviewing your design, I have replicated a similar layout using grid-based and flex approaches. Additionally, I have included gutter spacing for improved aesthetics.

I believe this updated layout will be beneficial to you.

.row div div{
    border: 1px solid #000;
    text-align:center;
}
.row .no-gutters{
padding:0px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

<div class="container">
  <div class="row">
    <div class="col-sm-2 no-gutters">
      <div>one</div>
    </div>
    <div class="col-sm-4 no-gutters">
      <div>two</div>
    </div>
    <div class="col-sm-2">
      <div>three</div>
    </div>
    <div class="col-sm-2">
      <div>four</div>
    </div>
    <div class="col-sm-2">
      <div>five</div>
    </div>
  </div>
</div>

<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>

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

How to achieve a seamless iframe effect using CSS

With the introduction of new HTML5 iframe attributes, there are now more options available. One such attribute is the seamless attribute, which has the ability to: Create an iframe that appears to be seamlessly integrated into the containing document. ...

A JavaScript String Utilizing an HTML Document

When developing applications for my website using JQuery, I encountered an issue with pulling an html document into a string. I want the application button to open a window with the html document inside. I am attempting to modify this string variable with ...

Transform input string containing newline characters into separate paragraphs

I utilize Contentful CMS for content management and fetch the content through their API. When the content is fetched, it comes in as a JSON object. One of the keys within this object pertains to the main text block for the entry I am retrieving. This stri ...

Balancing heights with jQuery

Is there a way to set the height of an h3 element based on the tallest version of its siblings, but only for certain elements? I have a list where CSS organizes items into rows of 3. The last li element in each row has the class "endRow". I want to find t ...

What is the best way to include a class with Knockout JS?

After going through the basic Knockout tutorial and examining various examples, I decided to try it out myself on jsFiddle. However, I encountered some issues as my attempts did not quite work. The goal is simple - I just want to add the class open to a d ...

Consistency in table cell formatting

What is the best way to ensure all my table cells have a consistent height and width, regardless of their content? I am working on a crossword puzzle game where some cells are empty, some contain letters as the user fills in words, and others display butt ...

I'm curious if there is a specific jQuery event that triggers right before an element loses focus or right before the next element gains focus

I am facing a situation where I have two input elements in a form that are closely connected. The first element triggers an ajax call to check for existing data in the database when the user tries to move away from it, while the second element opens a moda ...

Align the radio buttons vertically

My goal is to align all my buttons vertically, similar to the first question. However, I'm struggling to get the second question to align correctly. Despite trying different methods like using the vertical-align: middle property, nothing seems to be w ...

What is the best way to increase the padding in a Colorbox modal window?

Is there a way to increase the padding in a Colorbox modal window? I want some extra space between the edges of the modal window and the actual content. I experimented with the innerWidth and innerHeight properties, but unfortunately, I didn't notice ...

Convert SQL data into an HTML table using ASP

I have a database with an unknown number of rows containing columns for id and text. In my code, I am converting this data into a list of objects named news with parameters id and text. HTML <div class="middleDiv" id="mid" runat="server"> </div& ...

Having trouble getting my image and text to align properly in two columns

<img id="story_image" src="images/builder_story_side.png" alt="photo"/> <div id="story_right"> <h2 class="story_header">fdgdfgdfgdfgdfgfdgdfgfdgdfgdfgdfgdfgdfgdfgdfgdfgdfgfdgdfgdfgdfgdfgdfgdfgdfgdfgdfgdfgdfgdfgdfgdfgdfg</h2> <p ...

Ways to showcase a location on a map

Seeking a method to visually represent users' locations on a world map using HTML, JavaScript, or any other suitable approach. The data will be extracted from an Excel file and consists of the City Name only. Each user's location should be marked ...

If the desktop website is zoomed in beyond 150%, it will automatically switch to mobile responsive mode

Whenever the desktop website is zoomed above 150%, it automatically switches to mobile responsive mode. Is there a way to disable this feature? You can find the website in question here: Give it a try by zooming to 150 percent and see for yourself. Appr ...

Steps to deactivate a textarea in angularjs based on a selected option's value meeting a specific condition

Hello, I am a newcomer to AngularJS and I am looking to disable the textarea when a specific option is selected from a dropdown menu. I attempted to use ng-disabled="(here my ng-model value)" but unfortunately, it did not work as expected. If creating a ...

What is the reasoning behind the return type of void for Window.open()?

There is a difference in functionality between javascript and GWT in this scenario: var newWindow = window.open(...) In GWT (specifically version 1.5, not sure about later versions), the equivalent code does not work: Window window = Window.open("", "", ...

What is the best way to adjust the size of the box while ensuring that the text remains centered inside it

Consider the HTML snippet below: <div class='title'><h2>Title</h2></div> I attempted to adjust the size of the box with the following CSS: .title { display: block; border-radius: 12px; border: 1px solid; } The resultin ...

What role do colors and tables play in Javascript?

Preparing for my upcoming Web Development exam, I stumbled upon an intriguing question:https://i.sstatic.net/m9T0F.png Here's how I tackled it: function pallete() { var components = ["00", "33", "66", "99", "CC", "FF"]; var conte ...

Trouble with CSS styling arising when launching the MVC application on IIS

Currently working on a website in ASP.Net MVC 5. I am trying to test it on my local IIS (version 8), but encountering an issue where the CSS styling is not being applied. In my _layout.cshtml file, I opted for direct link tags instead of using bundles. &l ...

Limit of PHP string variable characters

I am working on an HTML survey where the answers are saved in variables and need to be inserted into a database using PHP. Here is an example of how the questions (part of a table) that can be filled out look like in HTML: <td style="padding-top: 10px ...

Creating an element in react-draggable with two sides bound and two sides open - here's how!

At the moment, I am facing an issue where the element is restricted from moving outside of the container with the class of card-width-height. My goal is to have the right and bottom sides bounded within the container while allowing the element to move beyo ...