On a desktop screen, there is a single tall div positioned next to two shorter divs. On mobile devices, the divs

Similar to the challenge posed in this thread, my query is slightly different.

I am looking to rearrange three divs on mobile devices while having them adjacent on desktop screens. Please refer to the linked images for a visual representation of the desired outcome:

https://i.sstatic.net/GWvF3.jpg https://i.sstatic.net/AFN2p.jpg

Describing this problem has proven challenging, so I've included screenshots to assist in understanding!

UPDATE: Below is a code snippet that addresses the issue by replicating existing code:

const Main = () => (
<section className="" id="section-2">
      <div className="container">
        <div className="row">
          <div className="col-12 d-md-none">
            <div className="text-center">
              <span className="text-uppercase small-text small-text--lighter">step 2</span>
            </div>
            <div className="text-center">
              <h2 className="text-center">HEADER 2</h2>
            </div>
          </div>
          <div className="col-12 col-md-6">
            <img alt="tbd" src="http://www.pixedelic.com/themes/geode/demo/wp-content/uploads/sites/4/2014/04/placeholder4.png" />
          </div>
          <div className="col-12 col-md-5 offset-md-1 text-center text-md-left">
            <div className="d-flex flex-column justify-content-between align-items-center align-items-md-start">
              <div className="d-none d-md-block">
                <span className="text-uppercase small-text small-text--lighter">step 2</span>
              </div>
              <div className="d-none d-md-block">
                <h2 className="">HEADER 2</h2>
              </div>
              <div>
                <p>SOME PARAGRAPH TEXT</p>
              </div>
            </div>
          </div>
        </div>
      </div>
    </section>
)
ReactDOM.render(
  <Main />,
  document.getElementById("react")
);
img {
  height: auto;
  width: 100%;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<div id="react"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"></script>

Answer №1

To ensure proper column alignment on larger screens, it's necessary to disable the flexbox feature in Bootstrap 4 as it makes all columns the same height. Instead, utilize floats so that columns B & C naturally shift to the right when A is taller. On mobile devices, you can use the order- class to rearrange the columns.

Arrange columns as A-B-C for desktop view and B-A-C for mobile view.

<div class="container-fluid">
    <div class="row d-flex d-lg-block">
         <div class="col-lg-6 order-1 float-left">
            A
        </div>
        <div class="col-lg-6 order-0 float-left">
            B
        </div>
        <div class="col-lg-6 order-1 float-left">
            C
        </div>
    </div>
</div>

For more information, refer to this post: Bootstrap with different order on mobile version

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

Unable to display routerLink within innerHTML in Angular

Within my component code, there is a field named "taggy" that contains a complete anchor tag. Initially, when I rendered it in my HTML, I only saw the contents of "taggy" displayed as text "<a href="blopp/1337">hazaa<a>". Clearly, this did not ...

Trouble arising when implementing media queries alongside jQuery

When the screen size is 768px, I need to trigger the code below by clicking on the next button. However, an issue arises when trying to revert back to the original style after changing the screen size: $(document).ready(function() { alert(); $ ...

Styling with CSS using the em unit to make an image half the size of its parent div element

I'm struggling with resizing an image within a div using the em size unit. I want the image to be half the size of its parent div, so I set both the width and height CSS properties of the image to 0.5em. However, when looking at the code below, you c ...

Tips for Printing a Page Using CSS and Bootstrap Formatting

I'm having trouble getting my website to print with its CSS and bootstrap styles. When I try to print using ctrl + p or the window.print() function, only the div, controls, and buttons appear without their corresponding colors. I've attempted to ...

Guide to Authenticating Users during Login or Registration with Django-Bootstrap-Toolkit

I'm currently working on authenticating a user in Django using the simple authenticate() function. def user_authenticate(request): if request.method == 'POST': auth_form = AuthenticationForm(request.POST) if auth_form.is ...

Click here for more information in JavaScript Reading Link

I am trying to implement a feature where I only display half of the text from a Biography field on the first page, and have a continue reading link that reveals the rest of the text when clicked. I would like to accomplish this using HTML. Can anyone p ...

What is the best way to extract clean text from HTML using JavaScript?

I am struggling with the code below in my HTML file: function hideContent(){ // Need help with this part! } <input type="button" onclick="hideContent()" value="Hide Content"/> <p id='txt'> <span class="A">I am</span> ...

Stop the text from wrapping to the full width of its parent when it overflows onto the following line

When I shrink the width in responsive design, the text overflows to the next line and the text wrapper expands to fit the parent container. Is there a way to prevent this behavior so that it looks like the red container? I could add padding to the contain ...

I'm trying to understand why this code isn't running properly. Can someone explain why my CSS is not being executed?

For some reason, using button .order{} to select elements inside the button is not applying the CSS codes as expected. The text color remains unchanged. However, when using just `.order` to select the elements, the CSS code works perfectly fine. Can someon ...

Angularjs drop-down menu changes images with animation

<body ng-controller="myCtrl"> <input type="checkbox" ng-model="loaded"/> <select ng-model="list"> <option ng-repeat="option in data.availableOptions" value="{{option.name}}">{{option.id}}</option> </select> {{list}} &l ...

The website link cannot be seen on Internet Explorer 8, however it is visible on other browsers like Firefox and Chrome

Please verify the following link: The link "Return to login page" is displayed correctly on Firefox, Chrome, etc., but it appears higher on IE8. How can this be fixed? To resolve this issue, you can adjust the CSS for the 'lost_password' div as ...

Customizing external elements with React's inline styling feature

Trying to use React to style elements generated by a third-party library has been a challenge. In the snippet below, I was able to achieve the desired styling using CSS, but now I am looking to accomplish the same using JavaScript. This way, users can defi ...

Warning from Cytoscape.js: "The use of `label` for setting the width of a node is no longer supported. Please update your style settings for the node width." This message appears when attempting to create

I'm currently utilizing Cytoscape.js for rendering a dagre layout graph. When it comes to styling the node, I am using the property width: label in the code snippet below: const cy = cytoscape({ container: document.getElementById('cyGraph&apo ...

Get all text that comes after a closing tag up to a designated tag using JSOUP

I have this snippet embedded within a plethora of table rows in a table: ......... <tr class="greycellodd" align="right"> <td align="left"> <input type="checkbox" name="cashInvestment" value="100468057"/> </td> <td align="left"& ...

Develop a Vue component for a fixed sidebar navigation

I am in need of a vertical navigation bar positioned to the left of my app's layout, with the content extending across the right side. However, I am currently facing an issue where the navbar is pushing all the content downwards. How can I resolve thi ...

Why @font-face doesn't display on older versions of Internet Explorer like IE 7 and IE

Our website has the following CSS code. The use of a smiley face is to ensure compatibility with IE 7 and IE 8. However, while the site's fonts display correctly on IE 9, Chrome, Firefox, etc., there seems to be an issue with IE 7 and 8. @font-face { ...

Creating an infinite loop of SVG rectangles pulled from a database

As I extract svg rectangles from a database using Python, I find myself hardcoding the process in order to change the colors of each rectangle in my CSS style sheet. With potential scalability issues in mind - if there were 100 rectangles - I am wondering ...

Adjusting element placement on collapsed navbar using Bootstrap

I've been developing a navbar for a webpage and have successfully aligned the data left and right with the Brand in the center. However, when the navbar collapses, the alignment shifts to Left (over) Brand (over) Right. I want the Brand to remain at t ...

Utilize JQuery to display a modal dialog within a pre-existing modal dialog

In my project, I am currently utilizing JQuery version 2.1.1 and JQuery UI version 1.11.0. My aim is to open a modal dialog within another modal dialog, with the primary (parent) dialog being disabled. While both dialogs have their modal properties set to ...

Discoloration of images on HTML5 Canvas

When working with HTML5 Canvas and using the drawImage function, I've observed slight discoloration in certain browsers such as Google Chrome and Mozilla Firefox. Interestingly, Internet Explorer and Chrome Android do not exhibit this issue. The globa ...