Adjustable HTML: Insert side panel between main column elements when wrapping

My goal is to create a simple columns layout like the one shown here: https://i.sstatic.net/o18xK.png

However, on smaller screens, I would like Component 2 to be positioned after Component 3:

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

Is there a way to modify the following HTML code to achieve this responsive layout?

<div class="row">
  <div class="col-lg-8">
    <div id="component1"></div>
    <div id="component2"></div>
  </div>
  <div class="col-lg-4">
      <div id="component3"></div>
  </div>
</div>

Answer №1

If you want to rearrange the order of elements, you can utilize the flexbox order property. With Bootstrap 4, you have access to Bootstrap's documentation on order classes.

For instance, in a Bootstrap example:

<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<div class="d-flex flex-nowrap bd-highlight">
  <div class="order-3 p-2 bd-highlight">First flex item</div>
  <div class="order-2 p-2 bd-highlight">Second flex item</div>
  <div class="order-1 p-2 bd-highlight">Third flex item</div>
</div>

Furthermore, Bootstrap offers responsive variations for order as well. Here are some examples of the class names:

.order-sm-0
.order-md-4
.order-lg-2

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

Achieving Perfect Alignment of Items in a Div With Centering

I've been struggling to center items both vertically and horizontally within a div. Despite searching on various platforms, I haven't been able to find a working solution. My goal is to have each item perfectly centered in its respective div, whe ...

Navigating child elements inside a parent container: A guide

Having trouble targeting the correct element in CSS. How can I get .sizewave to target both itself and .bp_bar? Any solutions? HTML: <div class="bp_outer_wrapper"> <img class="sizewave" src="media/images/heart.svg"> <div class="b ...

Tips for maintaining the nested collapsible table row within the main table row in a React MUI table

I am working on implementing a Material UI (MUI) table that includes collapsible table rows. The challenge I am facing is maintaining consistent border and background colors across all the rows, even when some are collapsed. Currently, the separate rows ar ...

Making sure that the anchor elements within a list are taking up all available space by setting them to display:block and adjusting their height/width

Looking at the example below, I want the anchor elements to take up all of the available space within their parent list items: http://jsfiddle.net/nmxmT/ I can't figure out what I did wrong :( ...

Error with column arrangement: absolute-positioned elements are displaying in the incorrect column

I'm currently trying to implement masonry layout using the CSS property column-count. While I am aware that there are simpler solutions involving creating multiple columns for the masonry structure, the complexity of my project built on PHP Laravel li ...

After fetching an HTML snippet using the $.get() method, Font Awesome icons are no longer visible

Experimenting with creating a seamless 'single-page' experience, I've managed to achieve this by implementing an event listener in jQuery for menu link clicks. This triggers the replacement of the existing content in my main div with an HTML ...

"Is it possible to create a single-page website with a unique logo for each div

Is it possible to have a unique logo on each section of my single-page website? Each section has its own div. Check out my website at . Thank you in advance! ...

What steps should I take to prevent my <mat-card> from expanding whenever messages are shown in Angular 9?

I have a <mat-card> containing a login form on my page. However, when error messages are displayed, the vertical size of the <mat-card> changes and I need it to remain the same. Is there a way to prevent this from happening? Below, you will ...

Using Javascript, display an image that was previously hidden with CSS when a radio button is selected

Within a table of 25 rows, each row contains an attribute accompanied by an image (represented by a tick symbol) and five radio buttons for rating the attribute from 1 to 5. Upon clicking one of the radio buttons, the hidden image (tick symbol) should beco ...

What's the best way to align two elements side by side regardless of window size changes?

I am looking to keep these two elements together in one row at all times, regardless of if the window is resized horizontally. Currently, they break into two rows as shown in this screenshot: http://gyazo.com/1820dc436dba2e827b330039109dc0ee I attempted ...

What could be causing my CSS and Bootstrap.css styles not to be implemented on my webpage?

While working on my Ruby on Rails application, I am trying to customize the design to resemble (which can be downloaded from ). However, I am facing an issue where the style sheets are not being applied. I have moved the style sheets from the bootstrap/c ...

Issue with line wrapping due to padding-left in IE7

My <font> element is having line wrapping issues in IE7, where padding-left:30px; or margin-left:30px only affect the first line. Unfortunately, since it's a web-app, I can't replace the <font> element with something else like a div. ...

Using javascript, hide or show a div without using jquery or the display:none property

I am looking for a way to show/hide a div up and down, but I have some requirements: I cannot use jQuery: toggle(), slideToggle(), fade, animate, etc. all use display: none, and I need the div to still occupy space in the DOM (I will be processing things ...

Mastering the art of utilizing particles.js

Particles.js doesn't seem to be functioning properly for me—I'm struggling to pinpoint the issue. Any guidance or suggestions would be greatly welcomed, as I'm unsure whether it's related to an external dependency... HTML: <div ...

The node.js and express.js update operation (CRUD) is not rendering the CSS files properly

I am currently developing a CRUD app using Node.js/Express.js with EJS as the templating engine. The concept I'm working on involves displaying user_ids from a database, and when an admin clicks on a user_id, it should redirect them to the edit_team. ...

Guide to incorporating vertical scrolling for a grid of items in Material UI

Is there a way to implement vertical scrolling in a grid container so that when the height of components exceeds a certain maximum, they can be scrolled through vertically? ...

Creating a unique HTML contact form in Insightly with properly aligned and spaced fields

Greetings, I must admit that my coding skills are quite limited and I am currently trying to navigate the world of HTML... As I attempted to integrate a basic contact form code from Insightly (provided below/attached), I came across this discussion here ...

Show information from mysql in a dual-column format

I am pulling data from a single table in mysql, currently displaying it in one column. I want the data to be displayed in two columns next to each other. You can check out the results at www.urimsopa.com Here is my current code: $results = $mysqli->qu ...

What is causing my mobile Bootstrap buttons to not function properly?

My website has buttons that function properly on desktop, but not on mobile devices. <button type="button" class="btn btn-primary rounded-0"><a href=" https://google.com">Google</a></button> I understand that on mobile devices, t ...

Update the background image every minute with a smooth transition effect

I am currently in the process of developing a personal dashboard that requires dynamic background images to change every minute. To achieve this functionality, I have integrated the [Pixabay API][1] and formulated the following API request: https://pixaba ...