What is the best way to position a div on the left side when it's large and move it to the

In my coding, there is a particular div element:

<div id="UnitInfoDiv" class="form-group row hidden">
    <div id=@UnitPartialViewHtmlId class="row"></div>

    <div class="row">
        <div class="col-md-6">
            Is the information about the current owner correct?
            @Html.RadioButtonFor(x => x.IsCorrectOwner, "true")Yes
            @Html.RadioButtonFor(x => x.IsCorrectOwner, "false")No
        </div>
    </div>
</div>

This div contains a partial view with the following content:

@model ServiceCallUnitDTO
<div class="col-sm-6">
    <h3>Current Owner</h3>
    @Model.CurrentOwner
</div>
<div class="col-sm-6">
    <h3>Warranty Information</h3>
    @Model.Warranty
</div>

When viewed on desktop, the Current Owner section occupies the left half of the screen, the Warranty Information is on the right half, and the radio buttons are below the Current Owner. This layout is satisfactory.

However, on mobile devices, the display shows the Current Owner at the top, the Warranty Information in the middle, and the radio buttons at the bottom.

I am seeking a solution to rearrange this layout for mobile devices, specifically wanting the Warranty Information at the top, followed by the Current Owner in the middle, and the radio buttons at the bottom.


I have referred to this Stack Overflow question about moving elements within a mobile layout, but the provided solutions did not align with what I require as they were focused on reordering items within the same column.

Answer №1

Big thanks to isherwood for guiding me towards the correct documentation. Once I made the switch to Bootstrap 4, the solution became incredibly straightforward. By utilizing the CSS class order-sm-{#}:

<div id="UnitInfoDiv" class="form-group row hidden">
    <div class="container">
        <div id=@UnitPartialViewHtmlId class="row"></div>
    </div>

    <div class="row">
        <div class="col-md-6">
            Is the Current Owner information accurate?
            @Html.RadioButtonFor(x => x.IsCorrectOwner, "true")Yes
            @Html.RadioButtonFor(x => x.IsCorrectOwner, "false")No
        </div>
    </div>
</div>
@model ServiceCallUnitDTO
<div class="col-sm-6 order-sm-1">
    <h3>Warranty Details</h3>
    @Model.Warranty
</div>
<div class="col-sm-6 order-sm-0">
    <h3>Current Owner Information</h3>
    @Model.CurrentOwner
</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

Tips for creating a responsive image using CSS

I am experiencing an issue with resizing a gif that I am trying to display on my screen. Here is the code snippet: import broomAndText from './ezgif.com-video-to-gif-3.gif'; import './spinner.css'; function myGif() { return < ...

Checkbox failing to pass value during form submission

Can anyone help me troubleshoot why my form isn't submitting a checkbox value when it's checked? <form action="codetest.php" method="get"> <div class=" form-check"> <input class="form-check-input" type="checkbo ...

Tips for positioning elements with a background on a mobile-friendly website

Currently, I am working on a responsive website that contains various graphical elements. One specific element includes a series of markers that are displayed along a pathway within the design. The amount of markers on the pathway can range anywhere from 1 ...

Styles are not being applied to the <label> element in CSS

While designing a form, I encountered an issue with applying CSS to set the size of the label and aligning it to the right for a more polished appearance. Here is the snippet of code I used: label{ width: 50%; text-align: right; } Link to Fiddle ...

Text does not conform to image boundaries

I've been having trouble with this issue and despite trying various solutions, I haven't been able to figure it out. I'm new to this so it's likely something very simple that I'm overlooking... .container { width: 80%; margin: ...

Ways to clear all CSS rules from a class without deleting the class itself using jQuery

Clear out all CSS properties within a class without actually removing the class itself using jQuery For instance : .ui-widget { font-family: Verdana, Arial, sans-serif/*{ffDefault}*/; font-size: 1.1em/*{fsDefault}*/; left: 350 ...

Adjust the color of both the image and text when hovering over either one

I need help creating a hover effect for an image and text pair. My goal is to have the image change when hovered over, along with changing the color of the text next to it. Below is the code I am currently working with: <ul id="recherche"> < ...

Horizontally align the elements within the card header using Dash Bootstrap

I am trying to align three components, html.div, dbc.Checklist, and dbc.Button horizontally within the card header of Dash Bootstrap. Currently, these elements are displayed vertically as shown below: https://i.sstatic.net/2Uhbq.png Is there a way to ch ...

Animate a Bootstrap icon displaying an unattractive border

When I click on a static Bootstrap glyphicon, I want to replace it with an animated one. My challenge is that if I use the replaceWith() function to completely swap out the icon, it looks great. However, if I try to just switch the classes using removeClas ...

Problem with Bootstrap loading state when certain input fields are required

Just starting out with Bootstrap 3 and looking to integrate the loading state button function into my form. I've set up an input field with the required option as shown below. <form> <input class="input" name="title" type="text" required / ...

Handling Pop-up Windows in Python with Selenium

# Automation Setup from selenium import webdriver from selenium.webdriver.common.keys import Keys from selenium.common.exceptions import NoSuchAttributeException, NoAlertPresentException from selenium.webdriver.support.ui import WebDriverWait from seleniu ...

Can Reactstrap integrate seamlessly with Bootstrap version 5?

I encountered an error while using reactstrap, bootstrap, and nextjs Server Error SyntaxError: The requested module 'react-popper' is expected to be of type CommonJS, which does not support named exports. CommonJS modules can be imported by impor ...

Can CSS content be used to showcase an .html document or .html fragment?

Referencing the MDN documentation for css content: /* <uri> value */ content: url(http://www.example.com/test.html); Inquiry: Can an image be displayed using the url() value of the content property in a css html element? .content { conte ...

Tips for concealing the edges of a scroll bar while utilizing scroll as overflow

Basically, I have a div that is positioned absolutely and has multiple children elements. This div can be scrolled horizontally to see all its content, but the scrollbar hangs off the bottom, hiding the bottom border radius. Here is the HTML code: <ul ...

The Bootstrap carousel spiraled into disarray

I am facing an issue with the basic bootstrap carousel. My goal is to make the slides move every four seconds. The current setup of the carousel code is as follows: $(document).ready(function() { fixCarousel(); }); function fixCarousel() { $('.c ...

How to vertically center content using Bootstrap 4 and Laravel

Seeking to achieve vertical centering of my column content. <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"> <div class="container d-flex h-100"> <div class="row mt-5 "> < ...

Picture in a clear background without any alteration

Is there a way to create a background-color with opacity inside an image without affecting the image itself? The issue lies in the fact that the transparent background-color makes everything underneath it, including text and the image, transparent. Below ...

D3 Chart: What is the best way to insert images into a node?

Within the jsFiddle demo provided in this query, there is code displayed. I am curious about how I can assign images to each node. var graph = { "nodes":[ {"name":"1","rating":90,"id":2951}, ] } You can access my jsFiddle Demo through this ...

Tips on preventing a div from being draggable within another div that is draggable

I have a plugin called Owl-Carousel that allows for sliding functionality. It automatically slides, but you can also manually slide it by dragging the slides. I want to insert some divs inside the slides; however, if the drag starts from that div, I don& ...

The dimensions of my textarea and input field are different

Just starting out with HTML and CSS here. I'm trying to use flexbox to create a form, but the width of my input fields and text area is off for some reason. Any ideas on what might be missing from my code? Thanks in advance! Here's the CSS I&apo ...