Leveraging Bootstrap 4.2 to Drag a Column from One Row to Another Within a Separate Column



Is there a way to move a column into a separate position, but within two different rows of the same column? I have included images below to illustrate my question.

https://i.sstatic.net/i0d4D.png https://i.sstatic.net/xXq6Q.png

I am looking to place "Blue" between "Red" and "Green" specifically for mobile and tablet views.

Your insights are valuable. Thank you!

Answer №1

My approach to this problem involves using Bootstrap and jQuery for a simple example, although I'm not sure how your code looks.

function resized(element) {
  const $element = $(element);
  const $box3 = $('.box3');
  
  if ($element.width() < 768) {
    $box3.insertBefore($(".box2"));
  } else {
    $(".box3-container").append($box3);
  }
}


$(document).ready(() => {
  resized(window);
});

$(window).on("resize", e => {
  resized(e.target);
})
body {
  font-family: sans-serif;
}
.box1,
.box2 {
  width: 200px;
  height: 100px;
  color: #fff;
}
.box3 {
  width: 300px;
  height: 300px;
  color: #fff;
}
.box2 {
  background: red;
}
.box1 {
  background: green;
}
.box3 {
  background: blue;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.2.1/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<div class="container">
  <div class="row">
    <div class="col-md-6">
      <div class="box-container d-flex flex-column">
        <div
             class="box1 d-flex justify-content-center align-items-center m-3 text-uppercase"
             >
          box1
        </div>

        <div
             class="box2 d-flex justify-content-center align-items-center m-3 text-uppercase"
             >
          box2
        </div>
      </div>
    </div>
    <div class="col-md-6 box3-container">
      <div
           class="box3 6 d-flex justify-content-center align-items-center text-uppercase m-3"
           >
        box3
      </div>
    </div>
  </div>
</div>

Check out the example on Codepen: https://codepen.io/pglejzer/pen/OJVbaXW?editors=1010

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

Bring the element to the top of the page by clicking on the anchor within the element or anywhere within the specified div ID

I am looking to implement a functionality where the page scrolls to the top of the navigation div ID when a link inside the navigation div is clicked, or ideally even when clicking anywhere within the div itself that contains the navigation links. After r ...

Header Blocks that are Fixed While Scrolling in fullPage.js Sections Using the "scrollOverflow: true" Feature

I am experiencing an issue where a fixed header on my website prevents scrolling through sections when hovering, specifically when the setting scrollOverflow: true is enabled. However, everything works fine and scrolling through all sections is possible w ...

Leveraging the power of map in an Angular typescript file

I've been attempting to populate a Map in Angular by setting values dynamically. When certain buttons are clicked, the onClick function is invoked. typeArray: Map<number,string>; Rent(movieId: number){ this.typeArray.set(movieId,"Rental ...

The combination of CSS3's 100% height and flexible boxes is resulting in unexpected and erratic

I'm attempting to design a webpage without a scrollbar by utilizing CSS3 box-flex. This is my current code: <html> <body style="height:100%;display:-webkit-box;-webkit-box-orient:vertical;"> <!-- height set to 1000px --> <div sty ...

Combine CRA with Craco to effortlessly integrate and switch between various CSS themes

Directory structure: src/index.tsx src/themes/dark.scss src/themes/light.scss ... Customizing webpack with craco: const path = require('path'); module.exports = { webpack: { configure: (webpackConfig, { env, paths }) => { webpa ...

Prevent my buttons from altering their color when hovered over

I have created some visually appealing buttons that I am satisfied with, but when a user clicks on one, the text color changes and the button's hover behavior is altered. I utilized this generator to design the buttons: Below is the CSS code for my b ...

Is it possible to show a success or error message upon form submission in Django without the need to refresh the page?

I created a quiz page that utilizes a "checkans" function to verify whether the user's answer is correct. My goal is to display a "Correct" message if the answer is right and an "Incorrect" message if it is wrong, all without redirecting to a new page ...

The headline is being improperly rendered inside a black box on Firefox

A while back, I inquired about creating a black box with padding around a two-line headline. The solution worked well, except for older versions of Internet Explorer. However, in Firefox, there are occasional issues with the display looking jagged. This oc ...

What is the best way to showcase an endless amount of items in a

I'm facing an issue with the layout of items in my view. I have a list of items, and I can display up to 6 items at a time using class="col-md-2". However, when there are more than 6 items, they move to the next row automatically. I want them to be d ...

How to create a MySQL query within an HTML select dropdown field

For example, <select><option>Price</option></select> $sql=mysql_query("SELECT `rug_catagory_id` , `rug_price` FROM `rugs_all_data` WHERE `rug_catagory_id` =1 ...

Update the table in a few moments

I am struggling to refresh my table every 5 seconds but haven't been successful. <table width="100%" class="table table-striped table-bordered table-hover" id="dataTables-example"> <thead> <tr> <th>Number</th> ...

Bootstrap 3 with a left sidebar menu featuring subtle ghosting borders for a sleek and modern

Hello there! I have a bootstrap 3 sidebar that seems to be causing some issues in IE 11. Specifically, I am encountering a strange ghosting effect on the border of the sidebar. When the page initially loads, only the bottom edge of the sidebar is visible. ...

Is there a method to track the progress of webpage loading?

I am working on a website built with static HTML pages. My goal is to implement a full-screen loading status complete with a progress bar that indicates the page's load progress, including all images and external assets. Once the page has fully loaded ...

Adjusting the Height of a Div Using a Single Button

Seeking help to make a div expand and then shrink with one button click. I've tried various methods but the div won't change size. Can someone guide me on why this is happening? Here is the code, CSS, and HTML for my latest attempt: $("dasButto ...

Customizing the field_error_proc in Rails is causing issues with the HTML layout

Within a rails application, I have customized the field_error_proc to enable inline error displays as shown below: https://i.sstatic.net/DjmdN.png The code snippet for achieving this functionality is outlined here: ActionView::Base.field_error_proc = pr ...

Enhancing TextFields with React Material Margins

I am facing a simple issue where I attempted to add marginButtom to the TextFields but for some reason, it is not applying any margin. Please take a look at this codesandbox link CLICK HERE CODE <label>Schedule</label> <Te ...

Is there an alternative solution to resolving this issue with OTP verification?

Working on a verification system where users are redirected to verify their account with an OTP code after signing up. However, I encountered an issue where the code doesn't seem to work as expected and no error messages are being displayed. <?php ...

Is it possible to use basic HTML for creating views within the Express framework?

I recently began using node.js in conjunction with the Express framework, but I'm finding it challenging to remove Jade and other templates from my project. I prefer writing my views in plain HTML. Can anyone provide guidance on how to achieve this? ...

When the browser tab icon does not appear, it is likely due to not responding to the GET /favicon.ico

I am running a web server for my basic HTML page that does not have a web icon included in the template. "HTTP/1.1 200 OK" Content-Type: text/html Connection: close <!DOCTYPE html> <html> <head> <met ...

I've encountered a peculiar error that is new to me while using bootstrap and javascript. Can anyone shed light on what this error signifies?

Hey there! I've come across this error in the console while attempting to utilize Bootstrap. It seems that a style is being refused from 'http://127.0.0.1:5500/node_modules/font-awesome/css/font-awesome.min.css' due to its MIME type ('t ...