Centering text horizontally in a column within a centered row using Bootstrap is not possible

Currently, I am in the process of creating a form and have encountered an issue. Specifically, I am attempting to center a row both horizontally and vertically within the layout but also need the text in the first column to be right-aligned. This first column contains labels that must appear on the left side of the input fields. Below is the snippet of code I am working with:

<div class="container">
    <div class="row justify-content-center align-items-center">
        <div class="col-md-3 text-right">
            <label for="numberOfPeople">Number of people</label>
        </div>
        <div class="col-md-7">
            <div class="p-inputgroup">
                <p-inputNumber inputId="numberOfPeople" [(ngModel)]="numberOfPeople"> </p-inputNumber>
            </div>
        </div>
    </div>
</div>

The main issue lies in the fact that the text within the first column remains centered despite my efforts. I have attempted adding the .text-right class directly to the label, as well as replacing the label with a p tag, however, these attempts have not yielded the desired result. While I would like to leverage Bootstrap's semantic classes to address this problem, it has been quite some time since I last worked with Bootstrap and I find myself struggling to achieve the intended outcome. Any suggestions or ideas on how to resolve this?

Answer №1

Which version of Bootstrap are you currently utilizing? As of Bootstrap v5, they have made the decision to "rename several utilities" in order to use logical property names as opposed to directional ones. This means that for v5, it is recommended to utilize the class text-end instead of text-right.

<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1a6865667d7a7d7b6879774441302d303e">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-9ndCyUaIbzAi2FUVXJi0CjmCapSmO7SnpJef0486qhLnuZ2cdeRhO02iuK6FUUVM" crossorigin="anonymous">

<div class="container">
    <div class="row justify-content-center align-items-center">
        <div class="col-md-3 text-end">
            <label for="numberOfPeople">Number of people</label>
        </div>
        <div class="col-md-7">
            <div class="p-inputgroup">
                <p-inputNumber inputId="numberOfPeople" [(ngModel)]="numberOfPeople"> </p-inputNumber>
            </div>
        </div>
    </div>
</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

What is the correct way to integrate HTML input elements into JavaScript code without encountering a type error?

I'm having some trouble with this code snippet. It's my first time coding and I can't figure out what's causing the issue. The error message I'm receiving is: "TypeError: Cannot read properties of null (reading 'value&ap ...

How to Make Bootstrap 3 Collapse Panels Stand Out with an Active Class

First of all, here is the fiddle link: http://jsfiddle.net/krish7878/h38jn324 I have a simple question. When a panel is clicked and it expands to show its contents, a class 'active' should be added to 'panel-heading'. I came across a ...

Prevent the underlining of the :before content of a link from being affected by a rule applied to the link

I have a hyperlink that becomes underlined when hovered over. I want to add a > symbol before the link, but I don't want it to be underlined when the link is hovered. Here's the code I'm using: .box.blueb a { color: #0098aa; } .box.blueb ...

Creating a custom CSS counter-style reminiscent of the toLocaleString function

Is there a way to customize the list counter style to display commas in the thousands place, similar to number.toLocaleString()? Or perhaps even adjust based on locale to show either 1,234 or 1.234? I have checked the Predefined counter styles but did not ...

Exploring the process of extracting/parsing HTML with Microdata

Hello, I am relatively new to the concept of Microdata. I currently have an HTML string that contains Microdata and I am interested in exploring the possibility of extracting the necessary information dynamically using Microdata with JavaScript or jQuery. ...

The mobile header appears without any background shading

Hey there, I'm encountering a puzzling issue: I have a header with a gradient background that displays perfectly on desktop. However, when I preview it on Chrome mobile emulator, it looks fine. But when I test it on an actual tablet or mobile device, ...

Issue with Angular/Chrome: The filter pipe is not able to be located

Even though this topic has been covered before, I have not found any satisfactory solutions. Here is my approach: play.module.ts import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; impor ...

What is the function of the Angular dependency injection mechanism?

I'm trying to grasp the inner workings of Angular/NestJs dependency injection. It's intriguing how the type of parameters gets lost when a Typescript class is constructed. For example: type Dependency1 = {}; type Dependency2 = {}; class X { ...

What steps should I follow to fix the "JIT Compiler Unavailable" error in Angular 13?

Currently, I am tackling a server-side routing project using Angular v13 and Express. My task involves creating a login screen to validate an ID and then redirect users to a home page. The issue I'm facing is that when I attempt to run my application ...

When using the `sendFile` method in Node.js Express, you will notice that the HTML content

Hey there, I'm new to nodejs and trying to create a simple website with two pages. I'm facing an issue where the content of the second file is being rendered as the first one, even though the source inspector in the browser indicates that it&apos ...

Loop through the elements retrieved by the `getElementsByName` method in

My goal is to access each node by elementName using the following JavaScript code: function myFunction() { var h1 = document.getElementsByName("demoNode"); for (var i = 0; i < h1.length; i++) { if (h1[i].name == "demoNode") { var att ...

I desire to share the JSON information and receive the corresponding response data

<!DOCTYPE html> <html lang="en" dir="ltr"> <head> <meta charset="utf-8"> <title></title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> </head> ...

Use desktop images to set the background for mobile views in a React JSX environment

My custom Gutenberg block is built using React JSX, allowing users to input two hero images - one for Desktop and one for Mobile. Currently, if a user does not upload a mobile image, it displays a blank space. I am looking for a way to have the desktop ima ...

Creating a sticky header for a MatTable in Angular with horizontal scrolling

Having an issue with merging Sticky Column and horizontal scrolling. Check out this example (it's in Angular 8 but I'm using Angular 10). Link to Example The base example has sticky headers, so when you scroll the entire page, the headers stay ...

Steps to opening a second hyperlink in the same window after initially clicking on Hyperlink1

I'm currently working on a project that involves a main web page with three links: Link1, Link2 and Link3. The requirement is for Link1 to open in a new window (window1) when clicked, while Link2 and Link3 should open in the same window as Link1 (wind ...

What is the reason behind fullPage.js only displaying the first page while hiding all others?

My website development is currently hindered by an issue with fullPage js. Only the first page is visible when using fullPage js, even though the links are properly set up on the dev site. As a result, I have to disable fullpage in order to make any progre ...

What is the best way to use Nativescript and Angular 2 to download a file and store it on the device?

Can someone provide guidance on how to download a file and save it to the device using Nativescript and Angular 2? I noticed there is a getFile function within the http module, but it doesn't seem to be available in Angular 2 () Additionally, I have ...

Live Server has been found to have its CSS implementation overriden by

Just diving into the world of web development, I'm currently working on a simple app using VSCode and the Live Server extension. Even though my files are correctly linked, some of the CSS changes like background color and font family don't seem ...

Traverse an array of nested objects in Firebase JSON notation

Currently, I am utilizing firebase4j, a Java library for Firebase. Although I understand that it is more optimal to use Node.js, I wanted to experiment with Java for this project. Within my database, I am required to store the URLs of images along with var ...

Which specific element of CSS should be adjusted to ensure compatibility with Internet Explorer?

Struggling with my one-page website layout, I made some adjustments to have six sections in the HTML. Everything seemed to work fine on all browsers except for Internet Explorer. It kept redirecting me to a weird spot between the second last and last two s ...