Is your Bootstrap input displaying the has-error class with a glyphicon, but the alignment is not vertically centered?

What is the reason for the misalignment of

glyphicon-warning-sign form-control-feedback
vertically in the code below after applying font-size: 20px; to the label?

<div class="container">

      <div class="content align-left contact">
        <p>Hello World!</p>
        <form action="#" method="post" id="contact-form">

          <div class="form-group has-error has-feedback">
            <label for="inputName">Your Name (required)</label>
            <input type="text" name="name" class="form-control" id="input-name" placeholder="Name">
            <span class="glyphicon glyphicon-warning-sign form-control-feedback" aria-hidden="true"></span>
            <span id="inputWarning2Status">(warning)</span>
          </div>

        </form>
      </div>

</div>

CSS:

.has-feedback .form-control-feedback {
    border: 1px solid black;
}

.content {
  padding: 100px;
}
.content p {
  font-size: 18px;
  letter-spacing: 1px;
  line-height: 30px;
  padding-bottom: 20px;
}
.content.contact label {
  font-weight: 700;
}
.content.contact label {
  font-size: 20px; //this is where the issue arises - but why!???
}

Result:

https://i.stack.imgur.com/QziwU.png

The warning text is not red either.

Any suggestions or solutions?

Check it out at jsfiddle, although I couldn't find bootstrap as the load option!

EDIT:

You can observe the bug at bootply

Answer №1

Although Brad's answer is good, it only addresses part of the issue. When you adjust the size of the label or add more content before the input field, the layout gets disrupted. To prevent this, make sure to enclose the .form-control-feedback element within a common parent container alongside the input field. Here is the CSS code to add:

.warning {
  color:#a94442;
}
.my-group {
  position: relative;
}

Don't forget to update your HTML as follows:

<div class="form-group has-error has-feedback">
    <label for="inputName">Your Name (required)</label>
    <div class="my-group">
        <input type="text" name="name" class="form-control" id="input-name" placeholder="Name">
        <span class="glyphicon glyphicon-warning-sign form-control-feedback" aria-hidden="true"></span>
    </div>
    <span id="inputWarning2Status">(warning)</span>
</div>

For a demonstration, you can check out this working demo: http://www.bootply.com/jGxRAFMKkg

Answer №2

1) To enhance your jsfiddle experience, consider incorporating external resources using the bootstrap CDN found on the left side of the screen.

2) The issue lies in the font-size set for the label, causing compatibility problems with the fixed icon. For further details, refer to bootstrap documentation.

3) HERE'S THE SOLUTION: Include the following CSS code:

.has-feedback label~.form-control-feedback {
  top:33px;
}
.warning {
  color:#a94442; /*apply this class to your warnings span*/
}

DEMO https://jsfiddle.net/10yLhpu3/

Answer №3

Make sure to include the following in your stylesheet:

.icon-warning{
  margin-top:10px;
}

#inputWarningStatus{
  color:#ff0000;
}

http://www.bootply.com/as89jdfFjf

By adding these styles, everything should function correctly.

Answer №4

Change the appearance of this element

.content.contact label {
  font-size: 20px; 
}

Add a cautionary message to this section

<span class="glyphicon glyphicon-warning-sign form-control-feedback warning" aria-hidden="true"></span>

Introduce a new class name and update the style previously removed with this change

.warning {
     font-size: 20px;
}

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

Activate browser scrollbar functionality

Below is the HTML code snippet: <html> <head> <style> #parent { position : absolute; width : 500px; height : 500px; } #top { position : absolute; width : 100%; height: 100%; z-index : 5; } #bottom { position : absolute; width : 100%; ...

Learn how to hide elements on print pages conditionally in Vue.js using CSS or JavaScript

I am currently using the Vue framework to work on printing webpages for my application. I have an issue that needs a solution, which I will explain below. <template> <div id = "intro" style = "text-align:center;"> <div ...

Deciphering the Mysteries of HTTP Headers

I have been using various applications to evaluate the quality of my websites, and many of the improvements suggested relate to missing http headers. Some examples include Content-Security-Policy, Charset, etc... I decided to visit the Wikipedia page on ...

Prisma encountered an error with the database string: Invalid MongoDB connection string

I'm encountering an issue with my MongoDB data provider, as I am informed that my connection string is invalid. The specific error message states: The provided database string is invalid. MongoDB connection string error: Missing delimiting slash betw ...

What is the proper way to place the authorization header for a background image using the url()

I am currently working on fetching background images through a REST API. However, in order to successfully retrieve these images, I have to go through an authorization process. The token required for authorization is already present in the context where ...

Expo: A guide on integrating expo code into an existing Android project

I'm looking to enhance my Android app (which is built in standard Java) by allowing users to create their own 3D models. To achieve this, I want to incorporate a 3D viewer within the app so that users can view and interact with their creations. My pl ...

Ajax transmitting data with concealed characters

I'm trying to send data from one PHP site to another. On the first site, everything looks good. The string appears as --show="author,book,text/n However, when I check the string after receiving it on the second site, it shows --show="author,b ...

The Jquery.post() function failed to trigger the callback

I'm encountering an issue with the JQUERY Post function. There are 2 functions that utilize the JQUERY Post function. Both of them work fine, but the callback function (handleLike) is not being triggered. Interestingly, when I manually call handleLi ...

Displaying fresh data from a JSON URL by clicking on a button and dynamically refreshing the view in

Apologies if this question has been asked before, but I couldn't locate it. I’m currently engaged in an Angular project where I’ve loaded an external JSON file using http. The data is presented through ngRepeat. When a button is clicked, I aim t ...

Utilizing the power of $.ajax() to parse through an XML document

I have a query about working with a large XML file containing 1000 nodes. Here is the code snippet I am using: $.ajax({ type: "GET", cache: false, url: "someFile.xml", ...

Tips for creating a Bootstrap table with a "table-bordered" style, fixed header, and scrollable body

How can I keep the table header fixed while allowing the body to scroll without breaking the table layout? I've tried using the CSS below, but it results in the width of the header columns being different from the width of the body columns. Any sugges ...

Using jQuery to extract information from a serialized array in ColdFusion

Recently, I made an update to a coldfusion function that now returns a string with additional serialized array data at the end. Despite realizing this may not be the most efficient method, I am currently constrained by this approach. var str = '1^Suc ...

VueJS form validation does not account for empty inputs in both fields

One of the challenges I'm facing is generating a form with Vue.js using the input fields below: { name: 'first_name', type: 'text', label: 'First Name', placeholder: 'First Name', ...

retrieve the Jquery progress bar's current value

Having trouble determining the value of the progress bar in order to increase it by a percentage with each step. No matter what I attempt, I keep getting errors such as 'undefined' or 'method cannot be called before object instantiation.&apo ...

What are the steps for installing the latest version of popper, v2?

When you run the following command: npm install popper.js --save You will receive a warning message that says: npm WARN deprecated <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="81f1eef1f1e4f3afebf2c1b0afb0b7afb0">[email& ...

The combination of HTML Agility Pack and VB.NET is a powerful duo for web

While there are numerous examples available for other programming languages, I am curious to know if there are any specifically for vb.net. Can anyone provide some relevant examples? ...

Leveraging $http or $timeout in conjunction with $stateProvider in AngularJS

I am seeking guidance on loading a template for a specific state in Angular using $http after coming across this question on Stack Overflow: Is it possible to load a template via AJAX request for UI-Router in Angular? The documentation for ui.router demon ...

The task of mapping an array of objects with nested values using JavaScript is proving to

Attempting to convert an array of objects with nested values in child objects like: const objs = [{ "B": { "value": 1, }, "D": { "value": "45" }, "E": { "value": "234" }, ...

Bootstrap Datepicker - dropup instead of dropdown

I'm a newcomer and have been struggling to set up the Bootstrap Datepicker. Whenever I try, all I see is the input field with the value "12-02-2013", but there's no dropdown menu when I click on it. Despite searching through various examples on ...

Access the filtered data with Vuex and Firestore to display the results

I am looking to enhance my project by implementing a filtering feature. I currently have a buttons component that will trigger the filter search. When I click the restaurant button, it should display the shops with a "Restaurant" value in Firestore. Conv ...