The suffix input-group-addon in Bootstrap 3 is not properly connected to the form field

Utilizing Bootstrap 3 within a C# ASP.NET MVC5 project.

I've encountered a peculiar issue while attempting to use input-group-addon to append a 'GB' suffix to a form field.

Here is the C# code snippet:

@using (Html.BeginForm()) 
{
    @Html.AntiForgeryToken()
    
    <div class="form-horizontal">
        <hr />
        @Html.ValidationSummary(true)

        <div class="form-group">
            @Html.LabelFor(model => model.capacity, new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                <div class="input-group">
                    @Html.TextBoxFor(model => model.capacity, new { @class = "form-control" })
                    <span class="input-group-addon">GB</span>
                </div>
                @Html.ValidationMessageFor(model => model.capacity)
            </div>
        </div>
    </div>
        
}

This corresponds to:

    <form action="/NewSpaceRequest/Create" method="post"><input name="__RequestVerificationToken" type="hidden" value="tP5XKKhflSS8K1e7q1I_ZSuR8Ty7X88FfuOMG5JhmF-KXtUOcn4SQdNGTMZZVC2pdBMjb7RgNrIB90Y9I5C_FgX9xmMLrwrbiFZde7PRZ13gCqjBDAVglM38T7j09-C-uNkRSCZbFqDgiU_XcH9D-w2" />
<div class="form-horizontal">
            <hr />

            <div class="form-group">
                <label class="control-label col-md-2" for="capacity">Capacity</label>
                <div class="col-md-10">
                    <div class="input-group">
                        <input class="form-control" data-val="true" data-val-number="The field Capacity must be a number." data-val-range="The field Capacity must be between 1 and 2147483647." data-val-range-max="2147483647" data-val-range-min="1" data-val-required="The Capacity field is required." id="capacity" name="capacity" type="text" value="" />
                        <span class="input-group-addon">GB</span>
                    </div>
                    <span class="field-validation-valid" data-valmsg-for="capacity" data-valmsg-replace="true"></span>
                </div>
            </div>
        </div>
    </form>

Do you notice how the suffix does not align properly with the form field?

The reason behind this remains unclear.

Answer №1

The ASP.NET MVC5 framework stack includes extra styles built on top of Bootstrap in the Site.css file, which sets a maximum width for input fields.

You have the option to delete this entire section.

By removing it, your form fields will become elongated. To fix this issue, I recommend changing col-md-10 to a shorter option like col-md-4, and you'll see a great improvement.

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

Gradual disappearance of preloader as the page loads

I'm facing an issue with setting a gif as a website preloader. Despite trying different JavaScript solutions, the preloader remains visible even after the page has finished loading. $(window).on("load", function() { $(".loading").fadeOut("slow"); ...

HTTP Service Causes PDF File Corruption

I have a PDF file stored on my server that opens fine when I view it. However, when I try to distribute the file using the following code: Response.ContentType = "Application/pdf"; Response.AppendHeader("Content-Disposition", "attachment; filename=Filena ...

A guide to accessing and extracting data from multiple files within a designated directory using C#

How can I retrieve and read the data from all files of any type, regardless of their extension, within a designated folder? ...

Need help with JQuery mouseOver fading in twice when you only want it to fade in

The version can be displayed here. I'm looking to have the current text fade away and the new text fade in. Strangely, it seems to fade in twice for some reason. $(window).load(function(){ var originalTitle = $('.Pinctitle').text(); $(&apo ...

Increasing margin and padding by a factor of two, achieved through the utilization of float and

Whenever I apply float or inline-block to elements, I notice that their margin or padding appears to be doubled. For example, the margin between the middle and bottom sections is set to 5%. However, the size of the top section is also 5%, but it is only ha ...

Bootstrap 5 - Creating a 3 Column Design with Right-Aligned Text Orientation

Currently in the process of designing a profile page. Would like the layout to resemble the image below: https://i.sstatic.net/Al4Tu.png Attempting to use col-sm-4 to separate columns, but facing issues with text alignment within the profile box. Seeki ...

Reloading the page to view real-time statistics

Is there a way to modify my page so that it displays today's statistics instead of hardcoded data? I'd like the data to be shown at specific time intervals and reset after a certain period. For example, 6am-2pm - 2pm-10pm - 10pm-6am. public voi ...

Acquiring a DataRowCollection

Is it possible to sort a DataRowCollection in ASP.NET WebForms like we do with a List in ASP.NET MVC? public DataRowCollection GetSortedRow(DataRowCollection dataRows) { var sortedResult = dataRows.OrderBy(d => d["Name"]) } Unfortunate ...

How to retrieve the width of an unspecified element using JavaScript

Seeking help with a div element that adjusts its size based on the elements it contains. How can I determine the final size of this dynamic div without checking the sizes of its internal elements? I've attempted to parse all the properties of the obj ...

Is it possible to make an element float or stay fixed on a web page based on the visible section of the page?

This question may be a bit confusing, but I couldn't phrase it any other way. Check out this link: Configure - Apple Store (U.S.) On the webpage, the 'Summary' box is positioned below the sub-header and aligns with the content block. When ...

Struggling to keep up with responsive behavior on a page featuring vertically and horizontally centered content that spans the full height

I'm working on a full-height website and the first section needs to have both vertical and horizontal centered content. The issue I'm facing is that there's an image included, which doesn't scale responsively when the screen size change ...

My requests and responses will undergo changes in naming conventions without my consent or awareness

Initially, I wrote it in a somewhat general manner. If you require more information, please let me know! This is how my C# class appears when sent/received on the frontend: public class Recipe : ICRUD { public Guid ID { get; set; } ...

A set of six DIV's, divided into two columns of three each

I'm attempting to arrange two columns with three vertical DIVs side by side. The left column is designated for main text, while the right column is reserved for miscellaneous information. Each column consists of a top and bottom DIV that display image ...

Interacting with the "onclick" event of a dynamically generated server-side TableRow

I am in the process of dynamically generating a table and I would like to make the rows clickable. When a user clicks on a row, I want them to be redirected to a page that is specific to the item in that row. My main query revolves around how I can link th ...

Tips for Arranging HTML Elements Next to Each Other with CSS3

As a beginner in programming, I am embarking on the task of creating a basic website inspired by a dribble design. I am currently struggling to align an image and text side by side within a section, so that they stack on top of each other when the screen ...

jQuery's capability to select multiple elements simultaneously appears to be malfunctioning

I am dynamically creating div elements with unique ids and adding span elements with specific CSS properties. $(".main").append("<div class=largeBox id=" + counter + "</div>"); $(".largeBox").append("<span class=mainTitle></span>"); ...

Working with asynchronous requests in .NET core

Seeking assistance in troubleshooting an issue with my ASP.NET Core project. While I am well-versed in using ASP.NET core, I am encountering a problem with .NET core C# "crashing" and exiting when attempting to make an async request. My code includes a me ...

What could be the reason behind the improper display of JavaScript for ID overlay2?

Why is it that when I try to have two overlays with different messages display upon clicking buttons, they both end up showing the same message? Even after changing the ID tag names, the issue persists. Can someone shed some light on what might be causin ...

I am struggling to prevent the background image from endlessly repeating despite my best coding efforts

I am struggling to correctly write the code to display the background image in this page only once, without repeating, and centered about 500px down the page. I tried something like "background-image: norepeat" but it didn't work. I looked at the W3C ...

Selecting between utilizing an abstract factory pattern or incorporating partial classes offers a distinct decision in the

Currently, I am working on developing a CRUD application using the Entity Framework Model First methodology. In my application's structure, both the UI Layer and DAL rely on the Domain Layer, while the Domain Layer remains independent. The Domain Laye ...