I'm looking for a CSS layout that can change the order of columns in a row stack for desktop view. Can anyone help me with this? (refer to

I am struggling with arranging elements in HTML and CSS. As a beginner, I am faced with the challenge of ordering desktop and mobile layouts differently. The current code I am using looks like this:

<div class="row ">
    <div class="col-lg-6">
        <img src="img/services/service1.jpg" alt=">
    </div>
    <div class="col-lg-6">
        <h2> Service 1</h2>
        <p>XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</p>
    </div>
</div>
<div class="row ">
    <div class="col-lg-6">
        <img src="img/services/service2.jpg" alt="">
    </div>
    <div class="col-lg-6">
        <h2> Service 2</h2>
        <p>XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.</p>
    </div>
</div>
<div class="row ">
    <div class="col-lg-6">
        <img src="img/services/service3.jpg" alt="">
    </div>
    <div class="col-lg-6">
        <h2> Service 3</h2>
        <p>XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.</p>
    </div>
</div>

This code currently arranges the elements in the following order:

1,2

3,4

5,6

however, I would like it to be:

1,2

4,3

5,6

I would appreciate any help or advice on how to achieve this arrangement. Thank you :)

EDIT: It's essential that the order remains 1,2,3,4,5,6 on mobile phones, which is why I am not swapping 3 and 4 for all devices.

Answer №1

Bootstrap 4 utilizes a grid system built on flexbox, allowing for reordering of elements. Refer to the reordering section in the Bootstrap documentation for further information.

Here is an example of how it can be implemented:

<div class="row ">
    <div class="col-lg-6">
        <img src="img/services/service1.jpg" alt=">
    </div>
    <div class="col-lg-6">
        <h2> Service 1</h2>
        <p>XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</p>
    </div>
</div>
<div class="row ">
    <div class="col-lg-6 order-sm-12">
        <img src="img/services/service2.jpg" alt="">
    </div>
    <div class="col-lg-6 order-sm-1">
        <h2> Service 2</h2>
        <p>XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.</p>
    </div>
</div>
<div class="row ">
    <div class="col-lg-6">
        <img src="img/services/service3.jpg" alt="">
    </div>
    <div class="col-lg-6">
        <h2> Service 3</h2>
        <p>XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.</p>
    </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

Unresolved Issue: Jquery Modal Fails to Activate on Subsequent Click for Ajax-

When I make an Ajax call, I load HTML into a div. This HTML content contains a jQuery modal that opens when clicked. However, on the first click, the modal opens correctly. On subsequent clicks, I receive the following error in the console: Uncaught Type ...

Guide on how to forward the response obtained from an Ajax call to a different HTML page

I am working with a mongoose database that stores data containing an individual's first and last name. The user inputs their first name into a field, triggering an ajax request sent to the file named controller.js. This file generates a JSON response ...

Firefox failing to display fonts from Google Font API

The landing page our company outsourced does not display the Lato font in Firefox, resorting to a different option instead. We have received a stylesheet from fonts.googleapis.com that includes the following: @font-face { font-family: 'Lato'; ...

defaultly collapse this panel

Looking for a way to have this panel collapse by default, as it currently opens when the page is loaded. I've searched online for solutions, but nothing seems to be working. <div class="col-md-12"> <div class="panel panel-default"> ...

Inserting a singular image following a designated list item

I have a question that may seem silly, but I'm trying to understand a specific CSS styling issue. I want to add an image targeting a particular li item. Currently, the code adds the image after all the li items: .menuStyling li:after{ content: u ...

Obtain data attributes using JQuery's click event handler

I'm facing an issue with a div structure setup as follows: <div class='bar'> <div class='contents'> <div class='element' data-big='join'>JOIN ME</div> <div class=& ...

Optimizing Image Size According to the Container, Not the Screen Size: A Guide

After exploring various resources on responsive images, I have come across a challenge that has me stumped. It seems like it should be simple, but I can't quite figure it out: How can I serve the appropriate image size based on container width rather ...

Strip inline styles from HTML content in django-tinymce

I am experiencing an issue with django-tinymce where it automatically adds inline styles when I save content. I would prefer to remove this behavior and only save the content in plain HTML. Can someone assist me with resolving this problem? ...

When the child element's "aria-expanded" attribute is set to true, a CSS class should be dynamically

Is there a way to apply a grey background to the first div when the dropdown is open? I've managed to add CSS based on the child elements' aria-expanding attribute, but I'm unsure how to do it for a parent element. Since I am using Vue, I pr ...

"Troubleshooting a Python MySQL error related to the WHERE clause

As a newcomer to the world of Python, I have recently created a small piece of code to establish a connection to a database and retrieve data from it. In this project, I am utilizing Python version 3.4 along with mysql.connector to facilitate the database ...

Styling text and images with Bootstrap

Currently, I'm utilizing bootstrap to structure a row with 2 div elements. The first div contains an image while the second div holds text content. The challenge I am facing is aligning the text to the edge of the image. However, since the image does ...

What is causing the lack of redirection with this particular "res.redirect()" function?

How can I successfully implement a redirection in a Node.js and Express.js application? When I attempt to redirect by clicking a button, only the URL changes without any further action taking place. Using a form with a button inside, the form specifies a ...

When clicked, elevate the element to the top of the window with an offset

Is there a way to click on this button, which is located within an accordion section header, and have it automatically move to the top of the page based on the window size? It seems like it should be a simple task, but sometimes after a long day things ca ...

JavaScript encountered an error stating "phone is not defined" due to an uncaught ReferenceError

Whenever I click on the Phone Number, it displays an error message saying that the function is not defined. How can I fix this issue? Thank you in advance! Here's the code snippet: <div class="product-label"> <h4><?php echo $p["Fu ...

Challenging substitution process within text fields on MS SQL

I have a large MS SQL TEXT field. My task is to clean it up, which includes identifying and removing chunks of HTML content intentionally stored within the text. This process involves modifying links, words, and formatting in these blocks of text across t ...

What steps should I take to adjust the price when multiple items are chosen?

I am working on a school project that requires JavaScript programming assistance. You can view the code here: https://jsfiddle.net/zvov1jpr/3/ HTML: <script src="java.js"></script> <div id="formular"> <div id=&qu ...

What is causing compatibility issues between Firefox and the provided CSS code?

I am experiencing an issue with the page layout in FireFox. The widths are not displaying correctly and the upload button does not work. However, I have no problems when using IE or Chrome. I have reviewed the code but cannot find any errors. Here is the ...

Reveal the concealed element

My webpage features a hidden span element within a div that I would like to reveal when a button is clicked. However, the functionality is not working as expected. Here is my code: <!DOCTYPE html> <html> <head> <meta charset="ut ...

Verify the presence of both class and id before modifying the content of the h1 tag and automatically redirecting the page

I'm encountering some issues triggering my JS/JQ on an HTML5 page. Essentially, I want to verify the existence of the following ID and class: ID: page_blog CLASS: page current <section class="page current" id="page_blog" style="z-index: 99; lef ...

Adjusting the transparency of the background without altering its colors

I need help figuring out how to merge custom palettes I've created such as this one, which resulted in a .css and .less file. While I want to retain the colors, I also require certain elements' backgrounds to be transparent. To achieve this, I c ...