Achieving Vertical Content Alignment in Bootstrap 4

I am struggling to achieve a responsive design where two columns stack vertically on top of each other when viewed on smaller mobile screens. Despite numerous attempts, I have been unable to figure it out.

Ideally, I want the layout to look like this image with buttons located below the content in mobile view:

Example

https://i.sstatic.net/V84I6.png

Your assistance with this issue would be greatly appreciated!

<div class="container">
  <div class="row">
    <div class="col-6">
      <h2 class="my-5">Lorem ipsum</h2>
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras metus ex, vehicula hendrerit neque vitae, consequat tristique enim. Fusce vel odio sed mi commodo dapibus. Aenean porttitor vestibulum purus, id feugiat dolor dictum a. Morbi non ipsum gravida, gravida sapien eu, tristique orci. Nullam rhoncus ornare varius. Mauris eget hendrerit nulla. Vivamus tempor hendrerit justo sed faucibus.</p>
    </div>


    <div class="col-6">
      <div class="row">
        <div class="col-12">
          <a class="btn btn-lg btn-outline-danger mt-5 mb-2 ml-5">Lorem Ipsum</a>
        </div>
      </div>
      <div class="row">
        <div class="col-12">
          <a class="btn btn-lg btn-outline-danger my-2 ml-5">Lorem Ipsum</a>
        </div>
      </div>
      <div class="row">
        <div class="col-12">
          <a class="btn btn-lg btn-outline-danger my-2 ml-5">Lorem Ipsum</a>
        </div>
      </div>
      <div class="row">
        <div class="col-12">
          <a class="btn btn-lg btn-outline-danger my-2 ml-5">Lorem Ipsum</a>
        </div>
      </div>
  </div>

Answer №1

This is working fine in a vertical layout. If it's not displaying properly for you, double check that you didn't accidentally close the container <div> with a </div>.

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
<div class="container">
  <div class="row">
    <div class="col-6">
      <h2 class="my-5">Lorem ipsum</h2>
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras metus ex, vehicula hendrerit neque vitae, consequat tristique enim. Fusce vel odio sed mi commodo dapibus. Aenean porttitor vestibulum purus, id feugiat dolor dictum a. Morbi non ipsum
        gravida, gravida sapien eu, tristique orci. Nullam rhoncus ornare varius. Mauris eget hendrerit nulla. Vivamus tempor hendrerit justo sed faucibus.</p>
    </div>


    <div id="buttons">
      <div class="col-6">
        <div class="row">
          <div class="col-12">
            <a class="btn btn-lg btn-outline-danger mt-5 mb-2 ml-5">Lorem Ipsum</a>
          </div>
        </div>
        <div class="row">
          <div class="col-12">
            <a class="btn btn-lg btn-outline-danger my-2 ml-5">Lorem Ipsum</a>
          </div>
        </div>
        <div class="row">
          <div class="col-12">
            <a class="btn btn-lg btn-outline-danger my-2 ml-5">Lorem Ipsum</a>
          </div>
        </div>
        <div class="row">
          <div class="col-12">
            <a class="btn btn-lg btn-outline-danger my-2 ml-5">Lorem Ipsum</a>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
    <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c0b0afb0b0a5b2eeaab380f1eef1f6eef0">[email protected]</a>/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" 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

Dealing with problems in col-md display on tablet devices

When viewing on Full Screen and mobile, the ranges panel (class="col-md-3") displays correctly. However, on tablet screens, the left column is obscured by the youtube image panel (class="col-12 col-md-9"). I have attempted various adjustments to the div s ...

show a different text when hovering over a table cell

I am working with a table where one column displays the employee ID, and I would like to show their names when hovering over it. Can someone assist me with this task? ...

Tips for showcasing beautifully formatted XML content on a webpage

I have some XML data that I want to display on my website, but I'd prefer to show it in a styled format like a bootstrap table. However, I'm not sure how to go about doing this. Here's an example of the XML: <?xml version="1.0" encoding ...

Modifying webpage code

I am looking to develop a system where I can edit various elements such as the navbar, paragraphs, and images directly from a web page. I understand that this can be achieved with JavaScript, but I am facing the issue of my customizations reverting to defa ...

Exploring AngularJS ng-repeat features for custom attribute settings

I'm currently facing a challenge in removing multiple repetitive divs by utilizing ng-repeat. <!-- I have 21 of these --> <div class="table-row"> <span class="glyphicon glyphicon-wrench"></span> <label>Chlo ...

How do you use CSS to replace an HTML "rules" attribute?

When publishing to HTML using the DITA Open Toolkit, certain inline table attributes are automatically applied such as frame="border" and rules="all". I am facing an issue where I need to override the "rules" attribute for table cells using CSS styles. Wh ...

Dragging and dropping elements onto the screen is causing them to overlap when trying

I am having trouble merging the drag and drop functionality from Angular Material with resizing in a table. Currently, both features are conflicting and overlapping each other. What I am hoping for is to automatically cancel resizing once drag and drop s ...

Strategies for restricting user input within a datalist

I have a project in which I am creating a webpage that displays a list of flights that can be filtered by destination, origin, price, and more. To achieve this, I have categorized each flight within a div element using its specific properties as classes. F ...

What is the best way to eliminate the space between columns?

I have a simple structure on BootStrap. <div class="container"> <div class="row"> <div class="col-md-4 blue-section" ><p>Some content</p></div> <div class="col-md-4 red-section"><p>Some content&l ...

What is the method used to calculate the heights of flex items when the flex-direction property is set to column?

I'm currently grappling with the concept of flexbox layout and have been exploring the flex-direction: column option. HTML <div class="container"> <div class="item"> Lorem ipsum dolor sit amet consectetur a ...

Align the headers of columns to the right in the AgGrid widget

Is there a way to align the column headers to the right in AgGrid without having to implement a custom header component? It seems like a lot of work for something that should be simple. You can see an example here: https://stackblitz.com/edit/angular-ag-g ...

Is there a way to apply the 'absolute' or 'fixed' with a width of 100% to the parent div specifically, rather than to the window size?

I would like to create a banner similar to the one shown here: https://i.sstatic.net/SZLr9.png I am attempting to achieve this using 'absolute' or 'fixed' positioning. However, when I tried using 'left: 0 right: 0 top: 0', i ...

Has window.document.height become obsolete in the latest version of Chrome, version 17?

After recently upgrading to the most recent version of Chrome (17.0.963.56), I've noticed that the property window.document.height is no longer valid. Has anyone else experienced this issue? I haven't been able to find any information about why i ...

Issue with implementing MUI Grid within a dialog across various screen sizes

While working with a MUI dialog and MUI grid, I encountered an issue. The code I am using is directly from the website, with only minor modifications to the dialog function names and the box wrapping the dialog. Despite changing the size of the dialog, t ...

Switching Background Colors with CSS

Can you change background colors using only CSS3? I attempted to use keyframe animations, but they only transition the background color. I simply want the background color to change after 5 seconds with no transition or hover effects. If I can fade it in ...

Arrange elements with Material-UI's Grid system

Check out my codesandbox example (here) showcasing how I have set up my current app with Material-UI grid. I have 5 components that need to be positioned in a specific way for different screen sizes. For screens sized lg and above, I want the components t ...

Create paper "cut" borders using HTML canvas or pseudo-elements

As a designer with a penchant for pain, I am striving to achieve an "art nouveau" aesthetic on paper for my NextJS project with MUI as the main design solution. Despite the abundance of CSS in the background, I am faced with the challenge of creating inner ...

The only functional button in the table is the one located on the top row

My MVC Application is encountering an issue with only the first item in the table working perfectly, while the rest are not calling the method. Despite my extensive research, I have been unable to resolve this issue. Below is the code on my view. Can someo ...

What is the process for choosing every child (regardless of level) of a parent using jQuery?

Is there a way to unbind all elements from a parent node using jQuery? How can I effectively select all children, regardless of their nesting level, from a parent node? I attempted the following: $('#google_translate_element *').unbind('c ...

Connect PHP code to an HTML document

Recently, I created an entry form login page saved as a .php file which displays content in html and css. The page showcases various elements followed by a login form with two fields: Username, Password, and a 'Log in' button. Additionally, I ha ...