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

JSON data for DataTables

I encountered a task that requires me to populate data in datatables from a JSON object. To achieve this, I implemented the following code: $('#example').dataTable( { "data": dataSet, "columns": [ { "title": "Engine" , "data" : "fieldName1"}, ...

Having trouble adding state values to an object

I have a specific state set up in my class: this.state = { inputValue: "", todos: [] } My issue lies within an arrow function where I am attempting to use setState to transfer the value of inputValue into todos. this.setState({ inputValue: & ...

Displaying HTML elements in a specific order using ng-repeat

Upon receiving the json message, my goal is to display it in HTML in a specific order. Within the json message, the position value indicates the desired order of elements, with 0 representing the first element in the array. At times, the json message may ...

npm: Import a package from a GitHub repository that does not belong to me

I have encountered a package that I need for my project, but it is not available in npm. I am considering the option of uploading the package to npm myself. However, I am unsure if this is ethically or legally acceptable. What is your opinion on this mat ...

We could not locate the requested resource with a DELETE request using the fetch JSON method

Currently, I am in the process of developing a webpage that utilizes JSON API REST alongside XAMPP with an Apache server. Up until now, everything has been working smoothly as I have been utilizing the DELETE method successfully. However, I seem to have hi ...

When using CSS border-width:1px, I notice that the borders aren't consistently thin

I'm attempting to add thin borders to a div. My CSS code is as follows: border: solid; border-width: 1px; However, the resulting borders appear unevenly thin in my browser. The borders on the left and bottom seem thicker than those on the right and ...

Tips for displaying a setCustomValidity message or tooltip without needing to submit the event

Currently, I am utilizing basic form validation to ensure that the email entered is in the correct format. Once validated, the data is sent via Ajax for further processing. During this process, I also check if the email address is already in use and whethe ...

What is the best way to set specific filenames in order to transmit them to the server?

Is there a way to send images files to a server using NODEJS without utilizing the traditional input file tag? I want to hard code the filepaths in an HTML client to achieve this. Are there any solutions available for this? Thanks in advance. ...

Concealing a div based on the checkbox's updated selection

Hello, I am currently working on a project that involves using both Angular and jQuery with checkbox controls. In this particular scenario, I have two checkboxes where selecting one checkbox should display its respective div, as each checkbox is associat ...

Can someone show me how to make an ajax request from a panel within a Firefox extension?

Seeking guidance on utilizing panels in the Firefox addon. How can I initiate an ajax request from a panel? Also, what is the best way to debug a panel since Firebug does not seem to recognize it? ...

Utilizing VueJS to Establish a Binding Relationship with Props

One of my Vue components is named Avatar.vue, and it is used to create an avatar image based on user-defined props. The parameter imgType determines whether the image should have rounded corners or not. Here is the code: <template> <div> & ...

Best method for creating HTML elements with jQuery

I've come across various styles and methods for creating elements in jQuery, each with its own unique approach. I am interested in discovering the most effective way to construct elements and whether a specific method stands out as superior for any pa ...

Display the URL with proper formatting in the print function

I am trying to create a table with clickable URLs in a "Link" column, but the URLs are too long and I want to show a custom title instead. So far, I have used the following code: str = "Test Title"; link = str.link("https://my_long_url.com/v1.0/ui/index. ...

Creating a CSS animation to repeat at regular intervals of time

Currently, I am animating an SVG element like this: .r1 { transform-box: fill-box; transform-origin: 50% 50%; animation-name: simpleRotation,xRotation; animation-delay: 0s, 2s; animation-duration: 2s; animation-iterat ...

Bizarre symbols observed while extracting data from HTML tables produced by Javascript

I am in the process of extracting data from Specifically, my focus is on the "tournament-page-data-results" div within the source code. Upon inspecting the HTML source code, the data does show up, but it appears with a mix of real information and random c ...

Can you create a while loop that continuously asks for user input, stores the responses, and then makes them accessible in an array?

When developing a Yeoman generator, the necessary dependencies can be found at https://github.com/sboudrias/mem-fs-editor#copytplfrom-to-context-settings and https://github.com/SBoudrias/Inquirer.js/. The main goal is to prompt the user with a question an ...

What are the best methods for creating genuinely random and highly secure session IDs?

I am looking to develop session middleware for Express, however, I am unsure about generating random and secure session IDs. How do larger frameworks like Django and Flask handle this issue? What would be the best approach for me to take? ...

Navigate to the AngularJS documentation and locate the section on monitoring data changes after a dropdown selection

Just starting out with AngularJS and Stack Overflow, so I hope I am asking this question correctly. I am working on a single-page application with editable text inputs. Two select drop-downs are used to control which data is displayed - one for time perio ...

Is the variable not being initialized outside of the function?

I'm really struggling with this async issue. I can't seem to get it to work because the summonerData array is not being set. I have a feeling it has something to do with async, but I'm not sure how to troubleshoot it. var summonerName = req ...

Ways to expand the height of a child element within a flex container that has been

I am facing an issue with stretching the children of a column flexbox container. While I can stretch one of the flexbox child elements, I am unable to stretch its nested children. Below is an example where .flex-child-2-child and .flex-child-2-child-child ...