Stop the Bootstrap row from automatically adjusting to the height of the tallest child column element, and instead utilize the extra space below the smaller element

My current framework is Bootstrap 5.2.
I am aiming to create two columns, each with a col-md-6 class inside a row. You can visualize the layout through this image: .

The challenge I'm facing is the inability to add another row with col-md-6 elements directly under the ExampleTitle column. This screenshot shows what occurs instead: .

To make my objective clearer, here's an image representation of what I'm trying to achieve: .

For inspiration, I discovered a design concept that aligns with my goals (scroll down on this page): https://css-tricks.com/snippets/css/complete-guide-grid/

.card2 {
  background: #2b2b2b;
  padding: 1rem 1.5rem;
  margin-bottom: 25px;
  border-radius: 16px;
}
body {
  background-color: #131313;
}
h1, h2, h3, h4, h5, h6, a, p {
  color: #fff;
}
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="2a4845455e595e584b5a6a1f04180419">[email protected]</a>/dist/js/bootstrap.bundle.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b6d4d9d9c2c5c2c4d7c6f68398849885">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container text-center">
  <div class="row">
    <div class="col-md-6">
      <h2>ExampleTitle</h2>
      <div class="card2">
        <h4>ExampleItem1</h4>
        <p>Description</p>
      </div>
      <div class="card2">
        <h4>ExampleItem2</h4>
        <p>Description</p>
      </div>
      <div class="card2">
        <h4>ExampleItem3</h4>
        <p>Description</p>
      </div>
    </div>
    <div class="col-md-6">
      <h2>ExampleTitle2</h2>
      <div class="card2">
        <h4>Service1</h4>
        <p>Something</p>
      </div>
      <div class="card2">
        <h4>Service2</h4>
        <p>Something that extends to a new line for varied heights</p>
    </div>
      <div class="card2">
        <h4>Service3</h4>
        <p>Something</p>
    </div>
      <div class="card2">
        <h4>Service4</h4>
        <p>Something</p>
    </div>
    </div>
  <div class="col-md-6">
      <h2>ExampleTitle2</h2>
      <div class="card2">
        <h4>Service1</h4>
        <p>Something</p>
      </div>
      <div class="card2">
        <h4>Service2</h4>
        <p>Something that extends to a new line for varied heights</p>
    </div>
      <div class="card2">
        <h4>Service3</h4>
        <p>Something</p>
    </div>
      <div class="card2">
        <h4>Service4</h4>
        <p>Something</p>
    </div>
    </div></div>
</div>

Answer №1

Is there a specific rationale behind leaving the contents of the third column untouched and not transferring them to the first column? If necessary, adding some top margin to the first child of the third column can create a visual separation. Here's an example:

.card2 {
  background: #2b2b2b;
  padding: 1rem 1.5rem;
  margin-bottom: 25px;
  border-radius: 16px;
}

body {
  background-color: #131313;
}

h1,
h2,
h3,
h4,
h5,
h6,
a,
p {
  color: #fff;
}
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="583a37372c2b2c2a3928186d766a766b">[email protected]</a>/dist/js/bootstrap.bundle.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a6c4c9c9d2d5d2d4c7d6e69388948895">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet" />
<div class="container text-center">
  <div class="row">
    <div class="col-md-6">
      <h2>ExampleTitle</h2>
      <div class="card2">
        <h4>ExampleItem1</h4>
        <p>Description</p>
      </div>
      <div class="card2">
        <h4>ExampleItem2</h4>
        <p>Description</p>
      </div>
      <div class="card2">
        <h4>ExampleItem3</h4>
        <p>Description</p>
      </div>
      <h2 class="mt-5">ExampleTitle2</h2>
      <div class="card2">
        <h4>Service1</h4>
        <p>Something</p>
      </div>
      <div class="card2">
        <h4>Service2</h4>
        <p>Something that is a longer sentence and will occupy a new line so that they arent the exact same heights</p>
      </div>
      <div class="card2">
        <h4>Service3</h4>
       <p>Something</p>
     </div>
     <div class="card2">
       <h4>Service4</h4>
       <p>Something</p>
     </div>
   </div>
   <div class="col-md-6">
     <h2>ExampleTitle2</h2>
     <div class="card2">
       <h4>Service1</h4>
       <p>Something</p>
     </div>
     <div class="card2">
       <h4>Service2</h4>
       <p>Something that is a longer sentence and will occupy a new line so that they arent the exact same heights</p>
     </div>
     <div class="card2">
       <h4>Service3</h4>
       <p>Something</p>
     </div>
     <div class="card2">
       <h4>Service4</h4>
       <p>Something</p>
     </div>
   </div>
 </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

In both Chrome and Edge, the default value for the <select> tag is successfully set, however, this functionality is not working in

I have defined two values in the created method, 2018 and My Name, and assigned them to separate data properties. These data properties are then passed as v-bind to a component. The issue I am facing is that in Chrome and Edge, both values are set as defa ...

Tips for aligning words on a single line

Encountering an issue with long words being split up in the middle of a line, as shown in this photo: https://i.stack.imgur.com/IxQi6.png This is the code snippet causing the problem: ineligiblePointsTableRows() { return this.state[PointsTableType. ...

The layout is being disrupted by a bug in the nested list div in IE 7

I am currently in the process of creating a website with nested lists in the sidebar. The parent list contains children li elements. Initially, only 4 list items are displayed, and the rest should be hidden with an option to "Show All" above them. Here is ...

The act of sorting an item in jQuery triggers a reordering of items

I am working with a collection of items that represent different layers within div elements. One of my goals is to ensure that when I rearrange these items, their corresponding div layers are also sorted accordingly. Here is the list of sortable items: & ...

Utilizing Ajax to Dynamically Update Link Styles

When using an AJAX request to load a portion of a webpage, the content is delivered by a framework and then inserted into the DOM tree using jQuery. Everything seems to be working well so far. However, I encountered an issue when trying to use background ...

What could be the reason for my code experiencing issues with fetching data from the database using a prepared statement

This is the PHP code I am using to retrieve data from a database using prepared statements. if ($conn) { //database connected successfully $view_sql = "SELECT * FROM certificate_verify"; $stmt_view = $conn->prepare($view_sql); $stmt_view->execute() ...

How can I include JavaScript in an HTML document?

My folder structure is as follows: Inside webapp/WEB-INF/some.jsp, I also have a javascript file located in the same directory at webapp/WEB-INF/js/myform.js. I referenced it in some.jsp like this: <script type="text/javascript" src="js/myform.js"> ...

Intrigued by the prospect of making HTML elements vanish or smoothly glide along with the content without obstructing it

I'm a beginner in coding and I want to make my website impressive. Right now, I have an HTML embedded element called "On this Page" that I would like to disappear when the user scrolls down the page. I've managed to position the element on the ...

Utilizing props to define the background-color of the '&:hover' state

I'm adapting Material UI's Chip component to accept custom values for the colors prop, rather than being limited to "primary" and "secondary". Additionally, I want the chip to exhibit a hover effect when clicked, transitioning to a different colo ...

Guidelines on Implementing a Three-Level Jquery Accordion Menu

Here is a snippet of jQuery code that I am working with: $(document).ready(function(){ $("#accordion2 h3").click(function(){ //slide up all the link lists $("#accordion2 ul ul").slideUp(); //slide down the link list below the h3 clicked - only ...

Utilize CSS transition to smoothly reveal a hidden div with a fading effect

I am trying to create a hover effect where a caption displayed over an image fades in with a background color change. I have attempted to use transitions but they do not seem to work for block elements. For the code and JSFiddle, please visit this link. ...

Shifting hues with every upward and downward movement

I am experiencing a small issue with this JS code... -I have multiple divs that are changing automatically in rows as they move randomly... I want to change the color of the div moving up to green. And for the div moving down, I want to change the colo ...

Firefox showing inconsistent jQuery positioning results

Here is a fiddle I created to demonstrate the issue at hand... https://jsfiddle.net/scottieslg/q78afsu8/10/ Running this fiddle in Chrome or Opera yields a value of 8. However, Firefox returns 9, and IE gives 8.5. How can I ensure consistency across al ...

Script for automated functions

I have implemented 4 functions to handle button clicks and div transitions. The goal is to hide certain divs and show one specific div when a button is clicked. Additionally, the background of the button should change upon hovering over it. Now, I am look ...

Is it possible to utilize CSS to generate a full-width slider while maintaining the aspect ratio of the content?

I am currently utilizing the unslider plugin to design a full-width slider header on a webpage (). Although it functions well at the dimensions I set it up for (1920x450), issues arise when viewed on different screen resolutions. See below: The background ...

CSS Styling for Adjusting Table Cell Widths

In my HTML table, I am trying to set the overall width while ensuring that the label column does not become too wide. Although it functions correctly in Firefox 4, IE 9 seems to be completely ignoring the width property. <html> <head> <sty ...

Is there a way to deactivate the spin buttons for an input number field?

Is there a way to create an input element with type number in Vue using createElement() in TypeScript and then disable the spin buttons for increment and decrement? I attempted to use the following CSS: input[type=number]::-webkit-inner-spin-button, input ...

The image fails to appear

Check out my website at www.wostokhr.pl I am having trouble getting the picture "pics/hero.jpg" to show up in the "div id="hero"" section with a JS parallax function. I have double-checked the HTML and CSS validators and everything seems to be correct. An ...

How can I adjust the padding and width attributes of the mat-menu in Angular 5

Today, I am struggling with a piece of code. Whenever I click on the Details button, it is supposed to open a mat-menu. However, for some reason, I cannot seem to adjust the padding or width of the menu: <div id="box-upload" [hidden]="hiddenBoxUpload" ...