Troubleshooting issues with Bootstrap's responsiveness configuration

I've been working on creating a responsive user login page using Angular 5. It looks great on full-screen display.

https://i.sstatic.net/YQrL5.png

However, when I resize the browser window, the responsiveness seems to break.

https://i.sstatic.net/4S5iy.png

Below are the HTML and SCSS snippets for reference. Can someone help me figure out what is going wrong here? Thanks in advance!

$ ng -v
Angular CLI: 1.6.1
Node: 8.9.4
OS: win32 x64
Angular: 5.1.1
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cli: 1.6.1
@angular-devkit/build-optimizer: 0.0.38
@angular-devkit/core: 0.0.23
@angular-devkit/schematics: 0.0.42
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.1
@schematics/angular: 0.1.13
typescript: 2.4.2
webpack: 3.10.0

admin-login.component.html

<div class="container">
  <div class="row">
    <div class="Absolute-Center is-Responsive ">
      <form (submit)="loginUser($event)">
        <div class="input" >
          <label>Username</label>
          <input class="btn-block" type="text">
        </div>
        <div class="input">
          <label>Password</label>
          <input class="btn-block" type="password">
        </div>
        <br/>
        <div class="input"> 
          <input class="btn btn-success btn-lg btn-primary btn-block btn-signin" type="submit" value="Login">
        </div>
      </form>
      <br/>
      <div>
        <a href="#" class="forgot-password float-left" style="font-size:20px">
          Forgot Password
        </a>
        <a href="#" class="forgot-password float-right" style="font-size:20px">
          Register
        </a>
      </div>
    </div>
  </div>
</div>

admin-login.component.scss

:host {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}


div.input {
    position: relative;
}

div.input label {
    position: absolute;
    top: 0;
    transform: translateY(-50%);
    left: 10px;
    background: white;
    font-size: 20px;
    padding: 5px 2px;
}

div.input input {
    padding: 10px 15px;
    font-size: 25px;
    outline: 0;
}

div.input {
    margin-top: 20px;
}


.Absolute-Center {
    margin: auto;
    position: absolute;
    top: 0; left: 0; bottom: 0; right: 0;
}

.Absolute-Center.is-Responsive {
    width: 50%; 
    height: 50%;
    min-width: 200px;
    max-width: 400px;
    padding: 40px;
}

UPDATE

Big thanks to @WebDevBooster for their insights! Following the guidance from https://getbootstrap.com/docs/4.0/layout/grid/ helped me address the alignment issue with my form and now everything is working smoothly.

Answer №1

The issue you're facing is due to the absence of a column. All content should be placed within a column that is nested inside a row, never directly inside a .row.

Bootstrap rows and columns are meant to be used together for proper functionality. It's important to always pair them.

Please note that in the code snippet below, using .col ensures the column will span full-width regardless of screen size. For better responsiveness, add appropriate responsive column classes accordingly.

You can place content directly within a .container without rows and columns, but keep in mind this approach won't be responsive. Once you introduce a .row, make sure to include at least one .col within that row and organize all content within those column(s).

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

div within a fixed width container with 100% width inside

Is there a way to ensure that div B has a width of 100% when nested inside Div A, which already has a fixed width? .divA{width:600px; margin:0 auto;} .divB{width:100%; height:20px; background-color:black} .filler{height:800px; background-color:grey} ...

Nested router-outlets in Angular are not functioning properly for routing

I'm currently facing a challenge with Angular routing in a scenario that involves nested router-outlets. The objective is to have an application-wide banner at the top, followed by a dashboard navigation component that has its own router-outlet for di ...

Difficulty replicating 3 input fields using JavaScript

Combining the values of 3 input fields into 1 Displaying 'fname mnane lname' in the fullname input field. Then copying the fullname value into another input field called fullname2. Check out the code below for both HTML and JavaScript implemen ...

Tips for removing the Y-Axis entirely from a CanavasJS chart

I'm working with a canvasJS chart and my goal is to completely hide the Y-Axis. I've managed to remove the Y-Axis line and title in this JSFiddle example. I came across these properties to hide the Y-Axis title and line, but I'm struggling t ...

Is it possible to create an HTML interface with Google Workspace Add-ons?

Recently, I've been on a mission to create a Google Workspace Add On that can display an iFrame. My journey led me to explore the documentation for Google Apps Script and Google Add Ons. From what I've gathered so far, it seems that I'll ne ...

Incorrect redirection using lazy-loaded modules

Encountering an Issue: Whenever I try to access localhost:4200, I expect to be redirected to different pages but it always redirects me to localhost:4200/login. I have 2 lazy load modules with childRoutes, but I'm confused as to why the redirection i ...

Displaying JQuery dialogs briefly show their contents before the page finishes loading

Utilizing jquery 1.10.3, I am creating a dialog that is quite intricate. When I say 'intricate', I mean that the dialog's content includes data from a database, such as dropdown lists populated by the results of database queries, alongside s ...

Fetching data from MySQL using Ajax technology

I need assistance with my form that is supposed to input a name and phone number, fetch data from a MySQL database based on the input values, and display the results. However, when I execute the query using an onclick function, instead of retrieving data f ...

The Fade In effect in jQuery causes my fixed header to overlap with images on the page

This is the javascript snippet using jquery <script type="text/javascript> $(document).ready(function () { $('#showhidetarget').hide(); $('a#showhidetrigger').click(function () { $('#showhidetarget&apo ...

How to Style an Element Based on Fragment Identifier in Href Attribute Using CSS

I've implemented the tabview feature from the YUI3 library. This is how the markup code appears: <div id="demo" class="yui3-tabview-content"> <ul class="yui3-tabview-list"> <li class="yui3-tab yui3-widget yui3-tab-selected"> ...

Accessing a JavaScript variable in another <script> section

I'm facing a challenge where I need to access a JavaScript variable that is declared in one block of an HTML page from another block on the same page. This is crucial for me to be able to halt an AJAX call that is currently ongoing. However, I'm ...

Adjusting the background width results in the container position being altered as well

Currently, I am working with two background images, each accompanied by a red box positioned absolutely inside a bootstrap container. The first red box is located on the right side and the second red box is on the left side. So far, everything is running ...

Is it possible to utilize the Worker class within React Native?

Is it feasible to execute the following code within a react-native environment? let worker = new Worker("./module.js", {type: "module"}); If this does run the module in a background thread, who is managing the thread marshaling process? Given that the Wo ...

Filter for the final item in Angular

Is there a way to create a filter that specifically retrieves the last element from a list? Alternatively, how can I implement a filter that excludes the last element? Context: I've got a list of items and I need to make sure the last item is editabl ...

struggling to update an array with user inputs on my to-do list app

I'm currently in the process of creating a small to-do list with some specific functionality. I want each text input (or a copy of it) to be added to an empty string, ensuring that the original input remains unchanged. The goal is to have a function t ...

Is it possible to swap out images using srcset attribute?

Currently, I am facing an issue regarding changing the img on mobile and tablet devices to display different images. As a beginner with jQuery, I couldn't resolve it using that framework, so I am exploring options with html5. I am wondering if there ...

An irritating bug causing a 1px difference in Chrome 21

Hey there, I've encountered a strange issue with the datepicker on this website. It works perfectly fine on IE8+, Firefox 14, Chrome 20, and Opera 12. However, as soon as Chrome updated to version 21, things went haywire! I'm baffled and can&apos ...

Using Angular 8, you can create a reactive form that includes a custom ng-select component which has

My custom angular reactive form includes a ng-select component along with other elements. I have implemented the following code to validate the form: private validateCustForm() { this.validation.touchFormControls(this.appointmentForm); if (this.ap ...

What steps do I need to take to develop a feature similar to Tabzilla?

Exploring the innovative navigation bar on Mozilla.org seems intriguing; commonly referred to as tabzilla, it smoothly moves down to reveal the menu at the top of the page. I wonder if there are any existing libraries or ready-made jQuery code snippets tha ...

Insert an ellipsis within the ngFor iteration

I'm currently working with a table in which the td elements are filled with data structured like this: <td style="width:15%"> <span *ngFor="let org of rowData.organization; last as isLast"> {{org?.name}} ...