Ensuring form labels are properly aligned with input-group-prepend in Bootstrap

Currently, I am developing a python/django website using bootstrap, and I have encountered an issue that I cannot resolve independently. It has been quite some time since I last worked with python/django/bootstrap, so I may be overlooking something?

<form action="" method="post" autocomplete="off">
{% csrf_token %}

{{ form.non_field_errors }}

    <div class="input-group mb-3 col-lg-4">
        <div class="input-group-prepend ">
            <span class="input-group-text" id="basic-addon1">Player Name</span>
        </div>
        <input type="text" class="form-control" id="player_name" name='player_name' placeholder="Player Name">
    </div>

    <div class="input-group mb-3 col-lg-4">
        <div class="input-group-prepend ">
            <span class="input-group-text " id="basic-addon1">Recruiter</span>
        </div>
        {{ form.recruiter }}
    </div>

    <div class="input-group mb-3 col-lg-4">
        <div class="input-group-prepend">
            <span class="input-group-text" id="basic-addon1">Notes</span>
        </div>
        <input type="text" class="form-control" id="notes" name="notes">
    </div>

    <div class="input-group mb-3 col-lg-4">
        <div class="input-group-prepend">
            <span class="input-group-text" id="basic-addon1">Accepted</span>
        </div>
        <select class="form-select form-select-lg" aria-label=".form-select-lg" id='accepted' name='accepted'>
            <option value="Not Yet" selected>Not Yet</option>
            <option value="No">No</option>
            <option value="Yes">Yes</option>
        </select>
    </div>

    <div class="input-group mb-3 col-lg-4">
        <div class="input-group-prepend">
            <span class="input-group-text" id="basic-addon1">Vote is up</span>
        </div>
        <select class="form-select form-select-sm" aria-label=".form-select-sm" id='vote_is_up' name='vote_is_up'>
            <option value="No" selected>No</option>
            <option value="Yes">Yes</option>
        </select>
    </div>
    <div class="form-check">
        <input class="form-check-input" type="checkbox" value="" id="archived" hidden>
        <label class="form-check-label" for="flexCheckDefault" hidden>
            Archived
        </label>
    </div>
    {% if form.errors %}
    {% for field in form %}
        {% for error in field.errors %} 
            <div class="alert alert-danger">
                <strong>{{ error|escape }}</strong>
            </div>
        {% endfor %}
    {% endfor %}
    {% endif %}
<button type="submit" class="btn btn-primary">Add</button>
</form>

In the image provided below, you can observe that the 'labels' are misaligned. My aim is to make them all equal in length for a neater alignment.

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

Answer №1

After discussing with Siddharth Bhansali, it was determined that a fixed width needed to be set in the custom CSS of the span element. The updated code now appears as follows:

<span class="input-group-text " id="basic-addon1" style="width: 115px;">

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

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

Retrieve user profile information for the authenticated user using Django REST framework

I have defined Models UserProfile, serializers and ModelViewSet as shown. My aim is to retrieve details of the currently logged in user such as state, city, address, etc from the models below. class UserProfile(models.Model): user= models.OneToOneFiel ...

Creating a toggle link with 5 different states in coding

I have an HTML table where certain TDs contain inline styles, title tags, and links. I am looking to implement a feature where users can hide these elements by clicking the same icon multiple times. For example, on the first click, only styles are removed, ...

Hide popup using HTML when clicking outside of it

Currently, I have implemented Bootstrap Popover with HTML content using the code snippet below. This code is based on the answer provided at . $(".song-status-link").popover({ html: true, placement: 'bottom', ...

Struggling with the conundrum of aligning a constantly changing element amid the

I was optimistic about the code I wrote, hoping it would work out in the end. However, it seems that my expectations might not be met. Allow me to provide some context before I pose my question. The animation I have created involves an SVG element resembl ...

"Utilizing custom data tags for woocommerce to display the product selling price with wc_rbp

When developing a website on WooCommerce, I encountered the need to create 6 different price lists with fixed prices for each product, while also being able to apply a global discount percentage for the price list assigned to each customer. To handle the ...

Can a layer be sliced to create a text-shaped cutout?

I want to achieve a cool text effect where the background is visible through the letters. I have explored options with background images and colors, but I haven't found any examples where the underlying layer is revealed. Is this even possible? Imag ...

What is the reason for the difference in width between Bootstrap-5 row and regular div blocks?

My code may seem simple, but I have encountered an issue with it: <link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="99fbf6f6edeaedebf8e9d9acb7abb7a9">[email protected]</a ...

Design an aesthetically pleasing chat interface using CSS styling

Currently, I am working on organizing HTML elements to create a user-friendly interface. Utilizing MVC and ASP.NET for this chat client, I have encountered an issue with correctly arranging the items. The default MVC project in Visual Studio provides a str ...

Guide on grabbing characters/words typed next to # or @ within a div element

Within a div element, I have enabled the contenteditable property. My goal is to capture any text input by the user after typing '#' or '@' until the spacebar key is pressed. This functionality will allow me to fetch suggestions from a ...

adjust highcharts chart size to fit screen width

Has anyone experienced issues with setting an explicit width of 400px on a chart? I am facing difficulties as the chart gets cut off instead of scaling down to that size. My main concern is having it resized properly for an iPhone mobile site. Can anyone ...

What is the inner workings of CSS?

I'm curious about the inner workings of CSS. Does the HTML get interpreted before CSS, or vice versa? Or does it all apply as soon as the browser has constructed the DOM? I would appreciate a detailed explanation on this topic. ...

Attempting to fill up a database table using a php iteration

My task is to populate a database table with more than 1,000 rows of data consisting of randomly generated numbers. Here is the code I am using: $input = new Card($request->all()); $i = 1; while($i <= 1000 ){ $input->pin = intval( ...

Why is my Datalist control not showing up in ASP.NET?

For the past few days, I've been working on dynamically generating labels using a DataList in ASP.NET code. Despite confirming that the data is being pulled into the datasource and seeing the control display correctly in the HTML code 'design&apo ...

Make sure to have the list available while choosing an item

I want to design a unique CSS element with the following characteristics: Include a button. When the button is clicked, a list of items (like a dropdown list) should appear. We should be able to select items by clicking on them, and the parent component s ...

A comprehensive guide to effectively formatting Recharts in React: addressing alignment and size management!

While attempting to style two graphs as floating cards, I am encountering difficulties in controlling the sizing and centering of the graphs. Specifically, I am having trouble with the pie chart in this example. To address this issue, I am passing paramete ...

Guide to Generating a Dynamic HTML Menu

Is "dynamically" the correct term for what I'm trying to achieve? * I am looking to have a basic one-level menu appear on every one of the 80 pages on my website. The menu items will be updated regularly - some added, some removed, and so on. What is ...

The spread operator seems to be malfunctioning whenever I incorporate tailwindcss into my code

Hi there! I hope you're doing well! I've come across a strange issue in Tailwindcss. When I close the scope of a component and try to use props like ...rest, the className doesn't function as expected. Here's an example: import { Butto ...

How to effectively manage multiple stylesheet links in React Native Expo development

Hello, my name is Antika. I recently embarked on a coding journey and have been focusing on learning HTML/CSS/JS along with the basics of React. As a beginner developer, my current project involves creating a Study planner app for myself using React Native ...

Tips for customizing the WooCommerce product page

If you want to customize the layout of a WooCommerce product page, you can override the template by copying the WooCommerce template folder into your theme. You can find step-by-step instructions here. I am looking to change the layout of a WooCommerce pr ...

Creating a modal popup when a button is clicked

After searching online for a way to make my sign up modal pop up when the signup button in my navbar is pressed, I was unable to find any information on how to achieve this. I suspect it involves JavaScript, but my knowledge of JS is limited. I attempted ...