How can I left align my text in Bootstrap?

Is there a way to left align 'Text' with 'Key Text'? Currently, it appears on the right side:

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

I tried using the pl-0 class, but it didn't work. How can I ensure that 'Text' is aligned to the left with 'Key Text' in this scenario? Here's the code snippet and a link to the corresponding JSFiddle:

.row {
  background: #f8f9fa;
  margin-top: 20px;
}

.col {
  border: solid 1px #6c757d;
  padding: 10px;
}
<script type="text/javascript" src="//code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<link rel="stylesheet" type="text/css" href="//stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
<script type="text/javascript" src="//stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">

<div class="modal-content pl-3 pr-3">
  <div class="modal-body">
    <div class="modal-body-scrolled border-primary border-bottom p-0 mt-2">
      <div class="form-row">
        <label id="lblFieldName" class="col-5 mb-0 text-primary font-weight-bold">Key Text</label>
        <div class="col-12">
          <div class="row ml-0 mr-0">
            <div class="row form-inline col-12 mt-2 mb-2 pt-2 pb-2 m-0">
              <div class="row col-12 pl-0 pr-0 mb-2">
                <label for="duration" class="col-2 pl-0">Text</label>
                <div class="col-10 pl-0 d-inline">
                  <textarea class="form-control" rows="2"></textarea>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

Answer №1

Make sure to include the justify-content-start class as well - you can see a demonstration below:

.row {
  background: #f8f9fa;
  margin-top: 20px;
}

.col {
  border: solid 1px #6c757d;
  padding: 10px;
}
<script type="text/javascript" src="//code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<link rel="stylesheet" type="text/css" href="//stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
<script type="text/javascript" src="//stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">

<div class="modal-content pl-3 pr-3">
  <div class="modal-body">
    <div class="modal-body-scrolled border-primary border-bottom p-0 mt-2">
      <div class="form-row">
        <label id="lblFieldName" class="col-5 mb-0 text-primary font-weight-bold">Key Text</label>
        <div class="col-12">
          <div class="row ml-0 mr-0">
            <div class="row form-inline col-12 mt-2 mb-2 pt-2 pb-2 m-0">
              <div class="row col-12 pl-0 pr-0 mb-2">
                <label for="duration" class="col-2 pl-0 justify-content-start">Text</label>
                <!-- ADDED 'justify-content-start' -->
                <div class="col-10 pl-0 d-inline">
                  <textarea class="form-control" rows="2"></textarea>
                </div>
              </div>
            </div>
          </div>
        </div>
      </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

Having trouble getting CSS Image Hover to work correctly?

I'm having trouble implementing a hover effect that changes the color of an image to blue when it is hovered over by the mouse. I've defined a class for the images and styled it in my CSS, but the effect isn't working as intended. I've ...

Dynamic video autoplay with a hover effect using Bootstrap 3

I am looking to create a hovering effect on an autoloop video similar to what is seen on this website - This specific section of the website demonstrates the effect I am trying to achieve. Prior to hovering, the autoloop video has an overlay displayed on ...

Having trouble with the Bootstrap 5 Modal? Discover how to ensure smooth functionality

How can I configure a Bootstrap 5 Modal to open only after clicking on a specific Navbar Dropdown item, without causing the whole website to be disabled and ensuring that all close buttons function correctly? <!doctype html> <html lang="en"> ...

Transforming a two-digit year into a four-digit year

Our entry form provides users with a calendar drop-down option, but they are also able to manually type in dates. We recently discovered that if someone enters a 2-digit year, it automatically changes to 1912 instead of 2012 (as dates cannot be in the past ...

Oops! Something went wrong: SQLSTATE[42S22]: Column not found - Error 1054: Unknown column '0' in the 'where clause'

I am encountering an issue with my Laravel page when attempting to implement a "soft delete" feature using the active field in the database. The error message I receive is: emails.ERROR: SQLSTATE[42S22]: Column not found: 1054 Unknown column '0&apo ...

I prefer not to receive the parent's opacity settings when styling a child element in CSS

Is there a way to prevent the child element from inheriting the opacity of the parent in CSS? I have a parent div and a child div inside it. I want to set the opacity for the parent div, but not have it affect the child div. Does anyone know how I can ac ...

Loading Website Content, Track your Progress

I'm facing an issue with the website loading progress bar. The script I'm using for the progress bar is not functioning correctly on the Web server www.example.com. Even though the website is live on the web server, the problem is that the progre ...

Turn off the background color box with a single click

Whenever I click on a header menu item, the background changes along with it. Is there a way to prevent this from happening? https://i.stack.imgur.com/p6bJ9.png Take a look here ...

Having Trouble with Centering in Bootstrap 4

I'm a bit puzzled about how to center the h2 element. This is my first time using Bootstrap 4, transitioning from Bootstrap 3, so maybe there's a difference that I'm not aware of? Any guidance on this matter would be greatly appreciated. Tha ...

Creating dynamic canvas elements with images using HTML and JavaScript

Currently, I am working on a unique project involving a canvas filled with dynamic moving balls. This project is an extension or inspired by the codepen project located at: https://codepen.io/zetyler/pen/LergVR. The basic concept of this project remains t ...

Different methods to incorporate Glyphicons without relying on Bootstrap CSS

For a recent client project, I utilized basic HTML and CSS. However, the client expressed a desire for Glyphicons to be included in the website menus. Attempting to incorporate Glyphicons with Bootstrap CSS posed challenges as it affected other aspects of ...

Turning my dual button navigation into tabs to display distinct HTML pages beneath a designated header

body{ background:url(background.jpg); background-size: cover; } h1{ font-family: 'Dancing Script', cursive; font-size: 5em; color: white; text-align: center; margin-top: 25px; margin-bottom: 20px; } h2{ font-size: 18px; color: white; text-align ...

What's the process for converting offsetX and offsetY pixel coordinates to percentages?

Currently, I am working on a project where I need the offsetX and offsetY coordinates to be displayed in percentage (%) format while hovering over a div element. By default, these coordinates are shown in pixels. Here is an example of the structure: < ...

What strategies can I use to ensure that the navigation bar is responsive when viewed on a

Check out my CSS file here for the navigation styling. See the screenshot of my HTML file showcasing the navigation panel here. I'm seeking assistance in making my navigation responsive on all mobile devices, as it is currently not functioning prope ...

Struggling with navigating segmented dropdown buttons

I was following a tutorial on Udemy to learn about inputs and dropdown buttons for bootstrap. Everything was going well until I attempted to create a simple selection of albums for one of my favorite artists. The buttons kept separating when I tried to cen ...

Is it possible to verify the presence of an ID with jQuery?

Is it possible to check for the existence of the id 'input-name' before assigning a value to the variable name using a line of code similar to this: var name = $('#input-name').attr("value"); In case the id 'input-name' does ...

Using jQuery to modify a CSS property when a specific option is chosen

I'm currently working on creating an option dropdown menu and I've hit a roadblock trying to display a textbox only when the 'other' option is selected. Here's what I have so far: <span id="con-country"><label for="count ...

Bootstraping Twitter with PHP session starting has become a standard practice in modern

Currently, I am developing a website using PHP and Twitter Bootstrap. The issue I'm encountering is that if I include session_start() first, the layout gets messed up because Bootstrap needs <!DOCTYPE html> to come before it. On the other hand ...

Placing an image in context with the background image

Looking for guidance on CSS styling. I have successfully set up a responsive background image on my page and now want to add a circular logo positioned at the bottom center of it. However, I am facing an issue where the logo's position changes when th ...

When scrolling, all sections display above the stationary header

On my home page, I have a header that remains fixed at the top of all sections. However, when I scroll down, the contents and sections appear above the fixed header, making it look like a background. Is there a way to ensure that all images and content go ...