How can I utilize Bootstrap ordering to rearrange the position of an element into a different column at a specific breakpoint?

I'm attempting to achieve a specific layout using Bootstrap order classes:

https://i.sstatic.net/NKhg9.png Currently, I have something similar to this setup (assuming all elements are of equal height):

<div class="row">
    <div class="col-3 order-lg-1 order-md-8">First element</div>
    <div class="col-6 order-6">Second element</div>
    <div class="col-3 order-lg-1 order-md-7">Last element</div>
</div>

On larger displays, the elements should be in a row as above. On smaller screens, I want the first and last elements to merge into a single column.

This layout can be achieved by combining the first and last elements into one:

<div class="row justify-content-around">
    <div class="col-6">Second element</div>
    <div class="col-3">
        <div>Last element</div>
        <div>First element</div>
    </div>
</div>

However, this approach will not work for larger displays as intended.

Another possibility is duplicating the first element and toggling its visibility based on breakpoints like so:

<div class="row justify-content-around">
    <div class="col-3 d-none d-lg-block">First element</div>
    <div class="col-6">Second element</div>
    <div class="col-3">
        <div>Last element</div>
        <div class="d-block d-lg-none">First element</div>
    </div>
</div>

But this solution feels somewhat hacky. Is there a purely CSS-based method to achieve this desired effect?

Answer №1

give this a shot

<div class="row flex-row-reverse flex-md-row">
    <div class="col-6 col-md-3  bg-success order-3 order-md-1">First item</div>
    <div class="col-6 col-md-6 bg-primary order-2" >Second item Second item Second item</div>
    <div class="col-6 col-md-3 bg-warning order-1 order-md-3">Final item</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

Turn off the scrollbar without losing the ability to scroll

Struggling with disabling the HTML scrollbar while keeping the scrolling ability and preserving the scrollbar of a text area. Check out my code here I attempted to use this CSS: html {overflow:hidden;} Although it partially worked, I'm not complete ...

observing which specific element corresponds to the nth child?

Exploring the concept illustrated in https://api.jquery.com/eq/, imagine a scenario with the following HTML structure: <ul> <li>list item 1</li> <li>list item 2</li> <li>list item 3</li> <li>list item ...

Using JQuery, retrieve the input from a text box within a table and save it as a variable

I am facing an issue with extracting and storing a variable from a textbox located within a dynamically generated table. My objective is to retrieve the value from the textbox within the dynamically generated table, and then save it to the database. The ...

What is the best way to set a cell's colspan based on a conditional value using AngularJS?

I am in need of displaying a row within a table with more cells based on a specific value found elsewhere on the HTML page. To ensure proper alignments and cleanliness, I am trying to find a way to dynamically set the colspan of a cell using angular. Des ...

Unable to access localStorage

I created a Plunker to store a value in localStorage: <!DOCTYPE html> <html> <script> localStorage.setItem('test', "hadddddha"); </script> </html> Then, I built a test page to retrieve the value from local ...

Some font-awesome icons are not appearing on the screen

As a beginner in web design, I am experimenting with using font awesome icons in Angular 9 projects within list items. While some of the icons are displaying properly, others are not. You can see the issue in the attached image. To access the icons, I have ...

Position the gameboard in the center of the box

I am struggling to find the best way to center a chess game board inside a colored box on my webpage. My main objective is to have the board vertically centered on the page regardless of the monitor width. I am torn between setting a fixed pixel width for ...

How can I create the effect of text changing color automatically after a specified time period has elapsed

I am currently dealing with a timer that is functioning properly, but I have a specific CSS inquiry. Essentially, what I would like to achieve is when the timer hits 30 seconds, I want the numbers to change to red color. $(function () { var $startTimer = ...

Can someone provide guidance on styling bidirectional text within a tooltip using bootstrap 4?

Is there a way to make Bootstrap tooltips display a mix of left-to-right and right-to-left languages, with the main direction being right-to-left? For example, I want the tooltip content to appear as "كلمة1 Word2 كلمة3 Word4 كلمة5", where the w ...

AngularJS fails to activate an event that is managed by addEventListener

I am currently attempting to activate an event on an <A> element using the mousedown event handled by a addEventListener call. However, I am puzzled as to why it is not functioning as expected. I attempted to utilize angular.element(el).triggerHand ...

What could be causing the div containing this flot chart to not resize properly when the $route is changed in AngularJS?

Whenever I navigate away from the main screen and then return, I notice that the graph does not resize correctly. Here is the HTML code, with some styling for debugging/testing purposes: <div class="panel-body" ng-show="graphType !== 'Mood Sentim ...

Tips for Creating a Responsive Homepage

I'm new to CSS and trying to create a responsive design for mobile IE. Currently, the page appears blank on IE but works fine on Google Chrome and other browsers :-) Here are the code snippets I have used: HTML: <div class="main"> <div ...

Integrate a PHP form that includes a redirect feature and an optional opt-in box

I'm a beginner and I'm trying to enhance this code by adding some extra features. When the form is submitted, I want the page to redirect to an external URL like www.google.com The checkbox should be automatically checked and when the client re ...

Minimize the empty space at the top of the website

Looking to eliminate the extra space at the top of this particular website. After attempting to use firebug, I still can't pinpoint the source of this unwanted spacing. Your guidance would be greatly appreciated. Thank you! ...

Difficulties encountered when launching a Meteor app with React using static-html

I'm currently working on a project that uses the Meteor framework along with React. When I attempt to start the application using the npm start command, I keep encountering errors related to static-html files. As a newcomer to Meteor, I've attemp ...

A simple guide on how to surround every incorrect input index in mapped inputs with red borders

I am incorporating a modal that corresponds each element of the object newCompanies to a specific row: {newCompanies.map((company, index) => { return ( <div> <div className="side- ...

Updating the scope variable in an AngularJS directive

Recently delving into Angular, I encountered an issue: I have both a list view and a details view with tags. To facilitate navigating between the two views and loading new elements from a service upon click events, I created a directive. My aim is to also ...

I am struggling to successfully upload a video in Laravel

In this section, the Ajax functionality is used to add a video URL to the database. The values for the Video title and description are successfully being saved in the database, but there seems to be an issue with retrieving the URL. <div class="m ...

Executing a C# method with an HTML button

My objective is to trigger a function using a button. Below is a simple code snippet that unfortunately isn't functioning as expected: @{ protected void displayMessage() { @<p>WELCOME!</p> } } <form> < ...

Is the form being submitted with the href attribute?

Does this code ensure security? <form id="form-id"> <input type='text' name='name'> <input type='submit' value='Go' name='Go'/></form> <a href="#" onclick="docume ...