The intricate arrangement of multiple rows and columns using Bootstrap 4 technology

Struggling with multi-nested rows and columns in Bootstrap 4, I encountered an issue where the line2 was positioned next to line1 instead of below it with a horizontal bar separating them. Can someone help me understand why this is happening?

<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container-fluid">
  <h1>Title</h1>
  <div class="row">
    <div class="col-lg-12 my-3 p-3 bg-white rounded shadow-sm">
      <h5 class="border-bottom border-gray pb-2 mb-0">Test 2</h5>
      <div class="row pb-3 mb-0 lh-125 border-bottom border-gray">
        <div class="col-md-3 media small">
          Some stuff
        </div>
        <div class="col-md-9 media">
          <div class="row pb-3 mb-0 lh-125 border-bottom border-gray">
            Line 1
          </div>
          <div class="row">
            Line 2
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

Even when using the same template with Bootstrap 5, the issue does not persist:

    <link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="593b36362d2a2d2b3829196c77697769">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet"/>
    <div class="container-fluid">
      <h1>Title</h1>
      <div class="row">
        <div class="col-lg-12 my-3 p-3 bg-white rounded shadow-sm">
          <h5 class="border-bottom border-gray pb-2 mb-0">Test 2</h5>
          <div class="row pb-3 mb-0 lh-125 border-bottom border-gray">
            <div class="col-md-3 media small">
              Some stuff
            </div>
            <div class="col-md-9 media">
              <div class="row pb-3 mb-0 lh-125 border-bottom border-gray">
                Line 1
              </div>
              <div class="row">
                Line 2
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>

Desiring to solve this issue while sticking to Bootstrap 4, I am seeking guidance on how to correct it.

Answer №1

In Bootstrap 4, col- is styled as flex box, while in Bootstrap 5 it is styled as block.

To make it block in Bootstrap 5, you can include d-block like this:

<div class="col-md-9 media d-block">

<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" />
<div class="container-fluid">
  <h1>Title</h1>
  <div class="row">
    <div class="col-lg-12 my-3 p-3 bg-white rounded shadow-sm">
      <h5 class="border-bottom border-gray pb-2 mb-0">Test 2</h5>
      <div class="row pb-3 mb-0 lh-125 border-bottom border-gray">
        <div class="col-md-3 media small">
          Some stuff
        </div>
        <div class="col-md-9 media d-block">
          <div class="row pb-3 mb-0 lh-125 border-bottom border-gray">
            Line 1
          </div>
          <div class="row">
            Line 2
          </div>
        </div>
      </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

Tips for converting JSON information on a website and inserting it into a designated division?

I've recently delved into front-end development, searching for solutions and hints without much success. I'm currently in the process of building my first website, specifically a "find recipes" website. Lacking knowledge of API calls, I created a ...

The DIV with looping functionality is not maintaining the table structure from the previous view

I have a table with a lot of ordering details. However, when I try to add a product from the admin page, the original table structure works fine. But as soon as jQuery adds an extra DIV to expand the table, I encounter issues. Can anyone suggest a jQuery m ...

jQuery UI dynamically adjusting content layout based on browser size changes

Having an issue with my custom accordion script where resizing the browser causes formatting problems in one of the sections. I want the content to remain intact and to utilize a scrollbar if necessary to view the content. The problem is visible in section ...

jQuery form validation not functioning as expected

I'm attempting jQuery form validation but encountering issues with the desired functionality. I would like the border of an input to turn red when it's empty upon focus out. Alternatively, I aim to incorporate the "has-danger" bootstrap class to ...

Having trouble getting the height to work properly on your Blogger Blogspot template?

Issue with embed height=100% not working <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr"> <head> & ...

How to implement a two-column layout within an IE contenteditable element

Currently, I am working on a contenteditable element that requires content to be displayed in a two-column layout. Users should have the ability to place the cursor anywhere within the text and move between positions using arrow keys. To achieve this, I a ...

Instructions on deactivating the background when the sidebar is displayed and closing the sidebar by clicking anywhere other than the sidebar

I'm in the process of creating a sidebar for my website. When the sidebar is displayed (by clicking showRight), I want to disable the background content so that the user can't interact with anything outside of the menu. If the user clicks on th ...

Encountered an unexpected "<" error while using Ajax with MySQL

I am trying to accomplish a simple task - retrieve a table from a MySQL database. Previously, I was using basic MySQL code and it was working fine. However, after switching to MySQLi, I encountered an error: Uncaught SyntaxError: Unexpected token < ...

When clicking, jQuery fails to hide the div

Here is some HTML code for you to check out: <div class="FormContainer" id="FirstFormContainer"> <form> <span> Enter the number of subjects</span></br> <input id="NumberOfSubjects" /></br> <span& ...

Adjusting image dimensions dynamically using JavaScript based on screen size

My bootstrap setup seems to be causing issues when using the @media (min-height: 1000px) rule as the image class does not respond as expected. I am looking to implement a JavaScript solution that will automatically resize images once the screen height exc ...

"Fixing the position of a div on the Samsung Galaxy S8 navigation bar to

Here is the HTML code I am working with: <div class="app-bar"> <a href="#'>icon</a> <a href="#'>icon</a> <a href="#'>icon</a> <a href="#'>icon</a> </div>' ...

Issue with Enter key not working on an individual textbox within Javascript/PHP chat functionality

Recently, I created a chat feature with text boxes that send messages when the ENTER key is pressed. However, I encountered an issue with it not working for the "Warning" functionality. Whenever I press Enter in this context, nothing happens. Can anyone pr ...

In order for the JavaScript function to properly execute, it requires the page to be

Check out this code snippet: <script> function scaleDown() { $('.work > figure').removeClass('current').addClass('not-current'); $('nav > ul > li').removeClass('current-li'); ...

Place a pair of divs in the center next to one another

What is the best way to align two divs in the center beside each other with some padding in between that actually works? I attempted using display: inline, but it didn't have the desired effect. .my-container { position: rela ...

Fade in and out on button press

There is a button with the following HTML code: <input type="submit" id="btnApply" name="btnApply" value="Apply"/> Upon clicking the button, a div should be displayed. <div> Thanks for applying </div> The display of the div should fade ...

Expanding Vue Tabs with Bootstrap: Manipulating tab-content to perfectly fill parent height

On my webpage, I have implemented a tabs component called b-tabs. This component is enclosed within a parent div with a specific height. I am trying to make the content of the tabs take up the full remaining height of the parent component. https://i.ssta ...

exploring various dynamic elements using jquery

If you need some help figuring this out, take a look at the JSFiddle here. I've set it up for users to input any data they want in the text box, choose a table from set one, and then click the "submit" button to send it. <div> <Div> < ...

Tips for making a JavaFX Button transparent without reducing the hitbox size

When I create a new Button in JavaFX and make the background transparent using either myButton.setBackground(Background.EMPTY); or myButton.setStyle("-fx-background-color: transparent;"), the hitbox is reduced to just the text inside the button when trigge ...

Guide to sending parameters using the POST method from page 1 to the iframe of page 2 via the GET method

The objective is to send a value to the iframe in candidatelogin2.asp from candidatelogin.asp. Within candidatelogin.asp: <form method="POST" action="http://127.0.0.1/hello/candidatelogin2.asp"> It is possible to retrieve the value from a hidden ...

The jQuery script seems to be failing to execute

Recently, I have been delving into the world of jQuery. However, after adding my code, the functions I set up are failing to run. Strangely enough, just two weeks ago everything was running smoothly without any errors in linking files within my HTML docume ...