Arranging Bootstrap 4 Right Column at the Top in Mobile View

My webpage is built using Bootstrap 4 and the layout looks like this:

<div class="row">
    <div class="col-md-8">
        Content A
    </div>
    <div class="col-md-4">
       Content B
    </div>
</div>

It displays as follows:

-----
|A|B|
-----

However, on mobile devices, Column A appears on top by default. I want to switch it so that Column B appears on top. Is this achievable with Bootstrap 4? I attempted using push and pull classes but had no luck.

Answer №1

Utilizing Bootstrap 4 opens up a range of possibilities with the following classes:

order-first, order-last, and order-0 to order-12

You can apply these classes to your elements for organized layout.

To learn more, check out this resource: Column ordering in Bootstrap 4

Answer №2

No examples were provided in the answers demonstrating how order-first functions, so here is an illustration:

<div class="row">
    <div class="col-md-8">
        A
    </div>
    <div class="col-md-4 order-first order-md-last">
       B
    </div>
</div>

When viewed on a desktop (md, lg, and xl) screen, it will apply order-md-last to maintain the current layout (B positioned below A).

On smaller screens such as mobile devices (xs and sm), it will utilize order-first to arrange B above A.

Answer №3

Have you attempted it this way?

<div class="row">
    <div class="col-md-6 col-sm-6">
        Hello
    </div>
    <div class="col-md-6 col-sm-6">
       World
    </div>
</div>

The Bootstrap grid system offers classes like col-xs, col-sm, col-md, and col-lg. These classes can be mixed and matched to create more dynamic and adaptable layouts.

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

Chrome does not support href while Edge does

href seems to be causing issues in Chrome, but it works fine on Microsoft Internet Explorer or Edge. It appears that the line (a href="....html")Something(/a) is not functioning properly on edge or safari. It behaves like a dropdown menu. There is a sig ...

Improper Placement of Bootstrap 5 Modal

I seem to be facing an unexpected issue where the Bootstrap 5 Modal and other components are displaying inside the sidebar menu instead of the main content area. Has anyone encountered this problem before? How can it be resolved? Here is a test example: ...

Adding a fresh, spacious breakpoint in Bootstrap 4 with just CSS

I encountered an issue when the extra large Bootsrap 4 max container width, set at 1140px, was not wide enough for my needs. I aim to ensure that my websites look good on large monitors as well, but the bootstrap grid is too narrow. The most straightforwar ...

How can you shift a button to the left side within a navigation bar?

I'm having trouble figuring out how to complete this simple task. The button needs to be placed on the left side. https://i.sstatic.net/zyqtJ.png html <body> <nav class="navbar navbar-dark fixed-top bg-info flex-md-nowrap p-0"> ...

When the horizontal scroll is turned off, it also disables the functionality of my mobile-friendly

I came across a helpful post on StackOverflow that suggested using the following code to disable horizontal scrolling: html, body { overflow-x: hidden; } This solution did resolve my issue of horizontal scrolling, but unfortunately it caused problems ...

Tips for maintaining consistent formatting of a div element across various sizes

Looking to create a Bootstrap Jumbotron that features a background image, text (h1 and p), and a call-to-action button that scales appropriately for different viewports without sacrificing formatting. Essentially, the goal is for the div to behave like an ...

modify the appearance of HTML controls in real time with C#

Is there a way to dynamically add an additional navigation item to my website's menu list when the admin logs in through admin.aspx? The menu list is created using HTML controls such as <ul>...<li>, and I would like the new navigation item ...

Creating personalized CSS for a Webix toggle button

I have been attempting to repaint a toggle button, but no matter what I do, I cannot seem to find the correct CSS style to override. The current setup can be viewed at CSS: .webix_el_toggle button{ background-color:grey !important; border-color: ...

What is the best way to integrate a PHP page with its own CSS and JavaScript into a Wordpress page?

I'm facing a challenge with integrating a dynamic PHP table into my WordPress page. Despite working perfectly when opened locally, the CSS and JavaScript used to create the table are not functioning properly when included in a WordPress page via short ...

Is there a way to align the input and button side by side using Bootstrap v5?

Is there a way to make my input textbox and button appear side by side without using the d-flex class in the div? I want to center align the content but removing the class messes up the alignment. Any suggestions on how to accomplish this? <!DOCTYPE htm ...

Changing the image source when clicking on it and removing it can be done by using JavaScript

How can I add a class 'selected' to ".swiper-slide" when it is clicked? I also want to change the image src when svg-img1, 2, or 3 is clicked. However, I need the image to revert back to its default src when another swiper-slide is clicked. ...

What is the best way to incorporate a dropdown menu into existing code without causing any disruption?

I've come across this question multiple times before, but I still haven't found a suitable answer or solution that matches my specific situation. (If you know of one, please share the link with me!) My goal is to create a basic dropdown menu wit ...

Implementing a Scroll Bar within a Stack Component in Material UI

I've developed a component and now I'm looking to enable scrolling when it expands beyond the screen width <Stack direction="row"> <Stack gap={1} overflow="auto"> {fields.map((el, i) => ( ...

How can I vertically align content in Bootstrap 4 without causing horizontal overflow on mobile devices?

Struggling with my registration page on the login form - I've utilized Flex and Vertical Align classes from Bootstrap 4 to center my div vertically. Works great on tablets and larger devices, but encountering an overflow issue on mobile devices: http ...

Dynamically adjusting CSS Max-Height according to scroll position

Is there a CSS only technique to achieve the following scenario: An element is positioned absolutely at x,y coordinates on the screen. The document includes a vertical scrollbar depending on its content. Can the height of the element be adjusted based on ...

What's the best way to add margin or padding to an SVG image within a v-app-bar

Seeking assistance with a seemingly simple question that can help enhance my understanding as I dive into using vue/vuetify for a new front end project. I am starting fresh and utilizing v-app-bar. Below is a snippet from my app.vue file: <template> ...

Creating a scrollable nested div on a mobile website

Is there a way to achieve a scrollable nested div on a jQuery mobile site? I am aiming for a fixed header and footer with the middle section being scrollable. Despite my attempts to set overflow:scroll (along with specifying the width and height of the div ...

`Trying to conceal the tr elements on button click proves tricky with jquery`

I have a pair of buttons, #btn1 and #btn2, as well as two table rows, #tr1 and #tr2. The goal is to toggle the active state of the buttons when they are clicked by the user. The specific requirements are: When the button is set to active, the elements ...

The dynamic trio of React-Bootstrap, PurgeCSS, and Next.js

PurgeCss seems to be causing an issue where it removes the react-bootstrap css classes used in my project, especially when I am using the Next.js framework. _app.js: import '../styles/style.scss'; import React from 'react'; import Prop ...

Is there a way to ensure that the text is positioned below the image with flexbox?

https://i.sstatic.net/c5xyr.png Is there a way to make the text fall underneath the image? I am familiar with using display: inline-block and float:left or float:right, but I am new to using flexbox. Can someone with more expertise help me solve this issu ...