Adjusting layout once image has been removed from view

I am working on a code where I want to hide an image on small screens and center the input fields when the screen size is XS. I have tried adjusting the Bootstrap 4 flex settings without success. Is there a way to achieve this using Bootstrap or SASS?

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"> {% block body %}
<div class="container d-flex">
  <div class="row justify-content-center">
    <div class="col-md-8 col-sm-8 col-xs-12">
      <form action="{{ url_for('register') }}" method="post" class="my-5" id="registrationForm">
        <div class="form-group">
          <label class="firstName" for="firstName">First Name</label>
          <input type="text" class="form-control" id="firstName" name="firstname" placeholder="First Name">
        </div>
        <div class="form-group">
          <label class="lastName" for="lastName">Last Name</label>
          <input type="text" class="form-control" id="lastName" name="lastname" placeholder="Last Name">
        </div>
        <div class="form-group">
          <label class="eMail" for="eMail">Email Address</label>
          <input type="email" class="form-control" id="eMail" name="email" placeholder="Email">
        </div>
        <div class="form-group">
          <label class="userName" for="userName">Preferred User Name</label>
          <input type="text" class="form-control" id="userName" name="username" placeholder="User Name">
        </div>
        <div class="form-group">
          <label class="passWord" for="passWord">Password</label>
          <input type="password" class="form-control" id="passWord" name="password" placeholder="Password">
        </div>
        <div class="form-group">
          <label class="passWord_2" for="password_2">Confirm Password</label>
          <input type="password" class="form-control" id="password_2" name="password2" placeholder="Confirm Password">
        </div>
        <div class="form-group text-center">
          <button type="submit" class="btn btn-primary custom-btn">Register!</button>
        </div>
      </form>
    </div>
    <div class="col-md-4 col-sm-4 flex-column my-5 py-3 align-self-center">
      <img class="img-fluid img-thumbnail d-none d-sm-block" src="/static/savoy.jpeg" alt="aubrey beardsley drawing" />
    </div>
  </div>
</div>
<!-- End form container -->
{% endblock %}

Answer №1

You can implement media queries to apply additional styles at specific breakpoints.

@media (max-width: 575px) {
  .row.center-on-xs{ margin: 0 auto; }
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"> {% block body %}
<div class="container d-flex">
  <div class="row center-on-xs justify-content-center">
    <div class="col-md-8 col-sm-8 col-xs-12">
      <form action="{{ url_for('register') }}" method="post" class="my-5" id="registrationForm">
        <div class="form-group">
          <label class="firstName" for="firstName">First Name</label>
          <input type="text" class="form-control" id="firstName" name="firstname" placeholder="First Name">
        </div>
        <div class="form-group">
          <label class="lastName" for="lastName">Last Name</label>
          <input type="text" class="form-control" id="lastName" name="lastname" placeholder="Last Name">
        </div>
        <div class="form-group">
          <label class="eMail" for="eMail">Email Address</label>
          <input type="email" class="form-control" id="eMail" name="email" placeholder="Email">
        </div>
        <div class="form-group">
          <label class="userName" for="userName">Preferred User Name</label>
          <input type="text" class="form-control" id="userName" name="username" placeholder="User Name">
        </div>
        <div class="form-group">
          <label class="passWord" for="passWord">Password</label>
          <input type="password" class="form-control" id="passWord" name="password" placeholder="Password">
        </div>
        <div class="form-group">
          <label class="passWord_2" for="password_2">Confirm Password</label>
          <input type="password" class="form-control" id="password_2" name="password2" placeholder="Confirm Password">
        </div>
        <div class="form-group text-center">
          <button type="submit" class="btn btn-primary custom-btn">Register!</button>
        </div>
      </form>
    </div>
    <div class="col-md-4 col-sm-4 flex-column my-5 py-3 align-self-center">
      <img class="img-fluid img-thumbnail d-none d-sm-block" src="/static/savoy.jpeg" alt="aubrey beardsley drawing" />
    </div>
  </div>
</div>
<!-- End form container -->
{% endblock %}

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

Presenting titles and buttons within a Bootstrap modal window

I have implemented a modal using vue-bootstrap. The code for the modal is as follows: <template id="child"> <b-modal v-model="showModal" size="lg"> <template v-slot:modal-header> <h4 class="modal-title"> ...

Adaptive Table Layout that Creates a Page-breaking Design

I have a page layout with three columns: a fixed-width left-hand navigation, a responsive content column, and a fixed-width right-hand navigation. The issue arises when the content in the middle column includes HTML tables that sometimes exceed the availab ...

Bootstrap causing issues with multinavibar functionality

Hi everyone, I have been using multinavbar but when I view it on mobile, the toggle and menu are not working properly. Below is the code snippet for reference: <div class="navbar navbar-default navbar-static-top" role="navigation" style="height: 114px ...

Leverage variables in JavaScript to establish a unique style

function AdjustScale(){ scaleX = window.innerWidth / 1024; scaleY = window.innerHeight / 768; element = document.getElementById("IFM"); element.style.transform = "scale(" + scaleX + ", " + scaleY + ")"; } I'm facing an issue with thi ...

Ways to generate multiple elements using JavaScript

Is there a way to dynamically freeze columns in a table as I scroll it horizontally? I've achieved this statically using JavaScript, but is there a way to indicate the number of columns and achieve the desired style? This is what my JavaScript code c ...

"Taking a break" and indulging in Sass

When transferring Sass classes from another project, I wanted to create a wrapper to contain these styles locally. Here is how my wrapper is currently set up: .my-wrapper { @include "framework-main" } Initially, everything seemed fine. However, I soo ...

What is the best way to position a button at the bottom using Bootstrap 4?

Currently utilizing Bootstrap version 4.0.0 Check out this example:: https://getbootstrap.com/docs/4.0/examples/pricing/ Is there a way to ensure a button is always at the bottom? Here's the jsfiddle link: https://jsfiddle.net/34shLh1m/ HTML Code: ...

Is there a difference in the functionality of CSS :invalid between Chrome and Firefox?

I am facing a challenge with styling my invalid elements in HTML forms. It is simple in Chrome, but Firefox seems not to recognize my :invalid pseudoclass. To see the difference, try opening the following code snippet in both Chrome and Firefox: <html& ...

What is the best way to monitor and record the height of a div element in a React application?

Exploring the Height of a Div I am interested in monitoring the height of a div element so that I can dynamically adjust distances based on varying screen widths. The animation should respond to changes in screen width, such as when text stacks and the he ...

Array of Ascending Progress Indicators

I currently have a progress bar that I'm happy with, but I want to enhance it by incorporating stacked progress bars. My aim is to have the progress bar behave in the following way when an option is selected: https://i.stack.imgur.com/Pw9AH.png & ...

Having trouble with Bootstrap 5 sticky-top functionality within a container?

Why is my <nav> not sticking to the top of the viewport when scrolling, even though it has the .sticky-top class? <!doctype html> <html lang="en"> <head> <meta charset="utf-8> <meta name="viewport" content="wi ...

Internet Explorer and CSS: How to eliminate a highlight that pops up when the button is clicked

Could you please check out this website in Internet Explorer (I've tried it on the latest version as well as older versions.) On the above link, there are two circular buttons at the bottom of the page. In IE, when you click on a button, a semi-trans ...

2 unique personalized classes with individualized modifications

Is it feasible to create 2 distinct custom (a tag) classes, each with unique class names? For Instance: When I try to use these in my HTML code, I struggle to create 2 different styles for (a tag) with different names! <a class="type1" href="#">te ...

Struggling to create a CSS dropdown menu where the dropdown items refuse to align to the left

I am currently working on creating a dropdown menu to reveal hidden elements on mobile devices such as smartphones. However, I am facing an issue where the child elements of the dropdown menu are appearing to the right of the parent element instead of the ...

The links are displaying on separate lines instead of being inline

There is a tags section on the blog detail page. The html code for it is as follows: <td class="tags"> <a href="">tag1></a>, <a href="">tag2</a> </td> However, the tags are appearing on separate lines instead of in ...

I'm puzzled as to why a scroll bar materializes

I recently encountered an interesting issue while working on my responsive web design project. Upon resizing the browser to a width of 615px or less, a horizontal scroll bar unexpectedly appeared. It's puzzling as to which element is causing this prob ...

Stop Bootstrap IE menu from closing when scrollbar is clicked

When using IE, the dropdown menu closes when clicking on the scrollbar. However, it functions properly when scrolling with the mouse wheel. To see the issue in action and potentially offer a solution, you can visit this Codeply link: I'm seeking sug ...

Collection of categories within the drop-down menu

I'm currently utilizing Twitter Bootstrap and would like to create a collection of concealed fields within a dropdown menu: <li class="dropdown"> <a class="dropdown-toggle" data-toggle="dropdown" href="#"> Export <b class="ca ...

Bootstrap 4 - DropDown option - Element is positioned above the navigation bar

Currently facing an issue with the DropDown menu. Whenever I add padding to the DropDown menu (class - drop_link), it ends up pushing the entire element over the <nav>. I'm unsure of how to prevent this from occurring. I attempted to disable som ...

Activate the active class on the icon when hovering over a dynamically generated span using Vue

Is it possible to activate multiple music notes when hovering over one? For example, if I hover over music note 2, both note 1 and note 2 should get active classes. And if I hover over note 3, then all three spans/icons should become active. I have succes ...