Reorganize content from one div to another when the screen size changes using Bootstrap

Creating a login screen with 2 columns has been my recent project.

For large screens: The left column contains the login controls while the right column displays an image.

On small screens: The top column shows the image, and the bottom column houses the login controls.

The functionality works as expected. You can see screenshots below:

https://i.sstatic.net/9zdq7.png

https://i.sstatic.net/3s2Xh.png

All is good so far. However, I aspire to have the "Sign in" and "Welcome" text within the image on smaller screens.

To better understand my goal, take a look at this Website's login page where they've accomplished it:

This is how my code looks currently:

<div class="container-fluid fullheight">

<div class="row fullheight">

  <div class="col-sm-12 col-md-6 col-lg-8 order-md-2 order-lg-2" style="background-color: grey;">
    this is my image panel
  </div>

  <div class="col-sm-12 col-md-6 col-lg-4 order-md-1 order-lg-1">

    <div class="loginarea">
      <h2>Sign in</h2>
      <p class="text-muted">Welcome to MySite. Please sign in with your email id and password to access your
        profile, reports and orders.</p>

      <form style="margin-top: 30px; margin-bottom: 20px;">
        <div class="form-group">
          <input type="email" class="form-control" placeholder="Enter email">
        </div>

        <div class="form-group">
          <input type="password" class="form-control" placeholder="Password">
        </div>
        <div class="form-check">
          <input type="checkbox" class="form-check-input" id="exampleCheck1">
          <label class="form-check-label" for="exampleCheck1">Remember Me</label>
        </div>
        <button type="submit" class="btn btn-primary float-right">Sign in</button>
      </form>

      <a href="#">Forgot password</a>
    </div>

  </div>

</div>

This represents my basic CSS styling:

   <style>
    .fullheight {
      height: 100%;
      min-height: 100%;
    }

    html,
    body {
      height: 100%;
    }

    .loginarea {
      margin-top: 100px;
      padding-right: 20px;
      padding-left: 20px;
    }
  </style>

I am seeking advice on integrating the text lines into the image and ensuring that only the login boxes are displayed in the white area. How can I achieve this?

Answer №1

If you are utilizing the most recent version of bootstrap, specifically version 4, then it is recommended to use the d-* class in the following manner.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container-fluid fullheight">

<div class="row fullheight">

<div class="col-sm-12 col-md-6 col-lg-8 order-md-2 order-lg-2" style="background-color: grey;">
this is my image panel
<div class="loginarea d-sm-none">
<h2>Sign in</h2>
<p class="text-muted">Welcome to MySite. Please     sign in with your email id and password to access your
profile, reports and orders.</p>
</div>
</div>

<div class="col-sm-12 col-md-6 col-lg-4 order-md-1 order-lg-1">

<div class="loginarea">
<div class="d-none d-sm-block">
<h2>Sign in</h2>
<p class="text-muted">Welcome to MySite. Please sign in with your email id and password to access your profile, reports and orders.</p>
</div>


<form style="margin-top: 30px; margin-bottom: 20px;">
<div class="form-group">
<input type="email" class="form-control" placeholder="Enter email">
</div>

<div class="form-group">
<input type="password" class="form-control" placeholder="Password">
</div>
<div class="form-check">
<input type="checkbox" class="form-check-input" id="exampleCheck1">
<label class="form-check-label" for="exampleCheck1">Remember Me</label>
</div>
<button type="submit" class="btn btn-primary float-right">Sign in</button>
</form>

<a href="#">Forgot password</a>
</div>

</div>
</body>
</html>

This code aligns with your expectations.

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

Encountering a RuntimeError during the integration of Angular Js in Rails with ExecJS

Currently, I'm working on integrating Angular Js into a Rails Project and I've been following the tutorial provided at . However, after completing all the steps, I encountered the following error: https://i.sstatic.net/ehYCb.png I've searc ...

Tips for repositioning the color picker

Here's a straightforward example where I'm looking to adjust the location of the color picker so that it aligns with the button. function changeColor() { document.getElementById('test').click(); } <div> <h1> Colo ...

Aligning a grid container in the middle

#panelb { background: lightblue; display: grid; grid-template-columns: repeat(auto-fit, 300px); } .card { background: gold; } .imgcard { display: block; width: 100%; margin: 0 auto; } <div id='panelb'> <div class=' ...

What is the best way to distinguish between a button click and a li click within the same li element

In my angular and css GUI, each line is represented as an li inside a ul with a span. The functionality includes a pop-up opening when clicking on the li background and another action occurring when pressing the button (as intended). The issue arises when ...

How can I convert a PHP class into inline CSS styles?

While exploring MailChimp's css inliner at , I found myself curious if there are any available classes that can achieve the same result. It would be convenient to have this functionality directly in my email code without relying on MailChimp. I am es ...

The min-height property in CSS appears to be ineffective on Jelly Bean

In my current project developing an Android application, I have incorporated Webviews in certain activities and fragments. However, I encountered a perplexing issue when running the app on Jelly Bean (api 16 and 18) emulator - the css property min-height ...

What would cause a flex-basis calculation to throw an error in SASS?

Today, I was working on a flex-grid generator in scss, which is something I do often. However, I encountered an unexpected error this time. I am using a 12-col-grid system and my approach should work fine with the code flex: 0 0 #{100 / 12 / $i}%;. There m ...

Finding the index of a selected option in node.js can be achieved using express

I am trying to retrieve the index of the selected object using Express and log it in app.js example.html <form id="tableForm" action="getJson"> <select class="example" name="example"> <option name="table1" value="1"& ...

Issue in Chrome where hover state does not persist after clicking, occurring sporadically

It's surprising that I couldn't find any information about this on Google. This bug is really annoying, and I'm not sure if it can be fixed without an update from Google for their browser. Description of the issue: When clicking on an eleme ...

Inconsistent column alignment in Bootstrap 4

Hello and thank you for taking the time to assist me. I am currently working with Bootstrap 4, but I have noticed that the grid system is quite different from Bootstrap 3. As a result, I am unsure if the layout issues I am experiencing are due to errors i ...

steps to retrieve JSON object using Angular service

In the login.js file, I have a module with a method called loginUser structured like this: ...function loginUser(){ var user={ email:loginVM.Email, password:loginVM.pwd }; console.log(user); loginService.login ...

Navigate to the top of the screen while in the Bootstrap section

I have successfully created a tab using bootstrap 4 with the following code: <section class="main-section lightblue " id="wstabs"> <a class="anchor" id="description"></a> <div class="bg-dark nav-tabs fixed-top" id="wstabs2" dat ...

Ways to create a vertical bottom-up tree view using d3.js

I am trying to create a reverse tree view, starting from the bottom and moving up. What modifications do I need to make? Here is the link to my JS Fiddle: ...

Add CSS styling to input text that is not empty

Is it possible to achieve this using CSS3 alone? var inputs = document.getElementsByTagName("INPUT"); for (var i = 0; i < inputs.length; i++) { if (inputs[i].type == "text") { if (inputs[i].value != "") { inputs[i].s ...

What is the best way to use html, css, jquery, and bootstrap to show or hide images without any extra space or alignment issues

I am looking to showcase 6 images on a page using the Bootstrap grid layout. The images should be displayed in two rows, with 3 images in each row. Additionally, I want to implement a filter functionality using Isotope, so users can click on a specific cat ...

Enhance User Experience in IE11 by Providing Font Size Customization with Angular (Using CSS Variables)

I am in the process of developing an Angular application. One of the requirements is to allow the user to choose between small, medium, or large font sizes (with medium being the default) and adjust the font size across the entire webpage accordingly. Wh ...

HTML border width is set to 100%, but there seems to be an issue with the responsive menu border and icon display

One issue I'm encountering with my website involves the border at the bottom of my navigation bar. Despite trying to adjust the box-sizing property to border-box, I still can't get it to display correctly. My goal is to have the border span 100% ...

I need to extract information from the database and save all entries from the form in order to send them to myself. This includes calculating the real-time multiplication of weight and pieces

For a project, I need to gather contact data from the client, and then populate a MySQL database with the information to create new rows in a table. There's an additional requirement where I have to calculate the total weight of element pieces multip ...

How can I use PHP to update and select on the same page simultaneously?

Having always been able to do something similar in other languages, I'm facing a few difficulties with PHP. My goal is to load a page that displays all the values from a form (created with a SELECT) and then update them all when clicking a "CHANGE" bu ...

Giving identification to a pair of elements located within the same column

Struggling with assigning IDs to two elements in a single column - a dropdown and a text element. Managed it in the first scenario, but encountering issues in the second one. Seeking assistance on this matter. Scenario 1: <td> <sele ...