Arrange and pile up 3 columns using Bootstrap 4

My project currently has a structure using bootstrap columns, as shown in the image below: https://i.sstatic.net/JufaU.png

However, I need to change to a lower resolution and rearrange the columns like this: https://i.sstatic.net/IB9sY.png

I came across a solution using flexbox on Stack Overflow: Flexbox: reorder and stack columns

Unfortunately, I can't switch my entire project structure to flexbox. Therefore, I'm wondering if it's possible to achieve the same result using Bootstrap 4.

Thank you for your assistance.

Here is a snippet of my code:

@import url( 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css' );

        div {
          text-align: center;
          height: 60px;
        }

        #left {
          background: yellow;
        }

        #middle {
          background: blue;
        }

        #right {
          background: coral;
        }
<div class="container">
        <div class="row">
          <div class="col-sm-3 col-md-3">
            <div id="left">COLUMN 1</div>
          </div>
          <div class="col-sm-6 col-md-6">
            <div id="middle">COLUMN 2</div>
          </div>
          <div class="col-sm-3 col-md-3">
            <div id="right">COLUMN 3</div>
          </div>
        </div>
      </div>

Answer №1

If you want to streamline your CSS, try utilizing the utility classes in Bootstrap 4 (alpha 6). This way, you can avoid unnecessary styling and create a responsive design that adjusts for mobile devices.

<div class="container">
    <div class="row">
        <div class="col-sm-8 col-md-6 push-md-3">
          <div id="middle">COLUMN 2</div>
        </div>
        <div class="col-sm-4 col-md-6">
          <div class="row">
            <div class="col-md-6 pull-md-12 flex-last flex-md-unordered">
             <div id="left">COLUMN 1</div>
           </div>
            <div class="col-md-6">
             <div id="right">COLUMN 3</div>
           </div>
          </div>
        </div>
    </div>
</div>

Answer №2

When you mention "resolution," are you referring to a smaller screen size?

To address this, I've come up with a potential solution that involves utilizing bootstrap push/pull grid tools to rearrange the columns in a medium-sized viewport. Then, for a smaller screen view similar to what you depicted in your diagram, I adjust the layout accordingly within a media query by using the CSS property order to vertically reorder the 1st and 3rd columns. Hopefully, this puts you on the right path.

<div class="container">
    <div class="row">
        <div class="col-sm-8 col-md-6 push-md-3">
          <div id="middle">COLUMN 2</div>
        </div>
        <div class="col-sm-4 col-md-6">
          <div class='row'>
            <div id='leftcont' class="col-md-6 pull-md-12">
             <div id="left">COLUMN 1</div>
           </div>
            <div id='rightcont' class="col-md-6">
             <div id="right">COLUMN 3</div>
           </div>
          </div>
        </div>
    </div>
</div>

CSS:

div {
  text-align:center;
  height:60px;
}
#left{background:yellow;}
#middle {background:blue;}
#right {background:coral;}

@media (max-width: 768px) {
  #leftcont { order: 2; }
  #rightcont {
    order: 1;
    margin-bottom: 1em; }
}

Check out the new fiddle

Please note that the div heights may need adjustment for different grid breakpoints. The colored divs were simply for testing purposes and weren't specifically matched to your example.

Answer №3

Did you attempt to extract data from the second column at a reduced resolution?

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 resolving the issue with "Text Animation"

Could someone please help with fixing this CSS animation? I want to align the text animation to the paragraph properly. I'm not confident if I am approaching this in the correct way, so if there is a simpler solution out there, I would appreciate lea ...

Any ideas on how to align the links in the navbar at the center of the image instead of having them at the top?

<!DOCTYPE html> <html> <head> <title>Funky Munky Arcade</title> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha ...

Looking for a creative way to make text reveal a background without using the standard clipping technique?

Take a look at the image attached to see the effect I am aiming for. Essentially, I am trying to make the background image show through the text, except where the text extends beyond the faded panel. In those areas, I need the text to blend in with the pa ...

What could be causing my React button to stop functioning as a link to an external website when using anchor tags?

I recently created some buttons for my website using React. Initially, everything was working perfectly with the buttons, but suddenly they stopped functioning. Strangely, I didn't make any alterations to the code and I'm puzzled as to why they a ...

Creating a list element after clicking in ReactJS is achieved by using event handlers in

I have buttons and inputs that I want to use to generate a list item in the ul section at the end of my code. However, despite adding functions to handle this feature, it still doesn't work as intended. import { useState } from 'react'; impo ...

Position the div to align with just one side of the table-cell

I am struggling with making the height of my code dependent on only the left column, while still allowing the right column to be scrollable if it contains more content than the left column. Despite my best efforts, I can't seem to figure out how to a ...

In IE, the hover state of the background color and sub menu is frequently toggling

I've been struggling with this issue all week. I have a CSS dropdown menu that uses both standard lists and content boxes as sub menus. The problem lies in IE, where each LI has an anchor tag that is set to display block in order to fill the parent LI ...

Button Menu in HTML

When you click the menu button, I want the text inside the class="greetings" div to change from "Welcome Jon deo" to just "G" So basically, whenever the menu button is clicked, display the letter G and hide or replace "Welcome Jon deo" Addition ...

The dropdown CSS menu appears to be malfunctioning

I've been struggling with creating a dropdown menu for some time now and I've reached a point where I need assistance. I've tried various solutions I found online, including watching tutorials on YouTube, but I can't seem to make it wor ...

Tips on ensuring a div containing an image element has equal height as the image

Here is the HTML code I am working with: <div> <img src="http://placehold.it/319x300" alt=""> <div> And the corresponding CSS: *{margin: 0; padding: 0;} div{ background: red; width: 319px; height: auto; } img{ width ...

The method item.appendChild does not exist as a function

Despite being a common error, I've researched extensively and still can't figure out why it's happening. It seems like it should be an easy fix, but I'm struggling to find the solution on my own. var item = document.createElement("div" ...

Using an image instead of a checkbox when it is selected (Angular 4/Ionic 3)

Is there a way to swap out the checkbox for an image? I want this image to change dynamically based on whether the checkbox is checked or not. Unfortunately, adding a class doesn't seem to do the trick as it modifies all icons in the same column. The ...

What is preventing me from clicking on the left side of the link on this CSS flip card while using Chrome browser?

When attempting to click the left side of the link on the back of this flip card in Chrome, it does not respond. However, hovering over the right side allows interaction with the link: /* Vendor prefixed by https://autoprefixer.github.io */ .card { ...

The CSS classes from Bootstrap are failing to function properly despite my best efforts in

I have been experiencing issues with the row and col classes in Bootstrap. <!DOCTYPE html> <html lang="en> <head> <meta charset="utf-8> <meta http-equiv="X-UA-Compatible" content="IE-edge> <meta name="viewport" content=" ...

JavaScript Error: Uncaught TypeError - The property 'remove' cannot be read because it is undefined

My modal window setup allows for opening two separate modals one after another, with the capability to close them individually (closing the second modal while keeping the first one active). (All the necessary code snippets are included below) let open_mo ...

Modify the sticky menu color upon scrolling

While working on a client's website, I've stumbled upon an issue that has left me scratching my head. I'm looking to modify the color of the sticky menu once it's scrolled. Can anyone assist me in creating a custom CSS code to implemen ...

Learn how to dynamically highlight a table row when any changes are made to it using jQuery

Is there a way to automatically highlight the current table row when any input text or image is changed within that specific row using jQuery? In the given code snippet below, with two rows provided, how can one of the rows be highlighted upon modifying ...

Trouble with z-index property within the confines of the <ion-segment-button></ion-segment-button> tag

The z-index property seems to be having no effect on the elements within the ion-segment-button. I attempted to adjust the positions of the elements and set the z-index to 999999 with the button z-index set to -1. However, this solution did not work as ex ...

The CSS file is not connecting properly despite being located within the same directory

I have double-checked that both of these files have the correct names and are in the exact same directory. However, for some mysterious reason, the CSS is not applying any styling to my page. I would greatly appreciate any assistance with this issue! Belo ...

Setting the width of a wizard modal to auto

I am facing an issue with my modal wizard. The width of the first modal is perfect, but when I navigate to the second and third modals by pressing next, they automatically take on a fixed width size that I need to modify. I have tried declaring the width ...