IE11 Floating Placeholder Label Bug Issue (placeholder-shown problem?)

While developing a login page, I encountered an issue where the label above a text input field did not float properly once text was entered in most browsers, specifically Internet Explorer 11.

I believe this problem is related to IE's compatibility with "placeholder-shown". The following CSS lines seem to be causing the issue:

.form-label-group input:not(:placeholder-shown) {
  padding-top: calc(0.75rem + 0.75rem * 0.66);
  padding-bottom: calc(0.75rem / 3);
}

.form-label-group input:not(:placeholder-shown) ~ label {
  padding-top: calc(0.75rem / 3);
  padding-bottom: calc(0.75rem / 3);
  font-size: 12px;
  color: #777;
}

I attempted to modify the code as follows:

.form-label-group input:not(:focus) {
  padding-top: calc(0.75rem + 0.75rem * 0.66);
  padding-bottom: calc(0.75rem / 3);
}

.form-label-group input:not(:focus) ~ label {
  padding-top: calc(0.75rem / 3);
  padding-bottom: calc(0.75rem / 3);
  font-size: 12px;
  color: #777;
}

However, this change did not resolve the issue in IE11. I am unsure of what other steps can be taken to address this problem.

Answer №1

If you're using IE11 or IE10, keep in mind that they use the non-standard :-ms-input-placeholder instead of the standard :placeholder-shown pseudo-class. Interestingly, MS Edge does not support either.

For a solution that works across different browsers, check out this related question.

Answer №2

Unfortunately, IE11 does not support CSS variables. For more information on browser support for CSS variables, please refer to the following link:

Link Description

To ensure compatibility, be sure to include a fallback for "var" in your code.

Answer №3

After troubleshooting, I discovered the root cause was related to the behavior of "placeholder-shown" in CSS.

To address this issue, I implemented a JavaScript solution to replicate the functionality provided by CSS's "placeholder-shown".

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

Selecting CSS Properties with jQuery

I am trying to make an image change color to blue and also change the background color to blue when it is clicked inside a div. However, my code doesn't seem to be working as expected. Is there a more efficient way to apply CSS to elements? FIDDLE v ...

Checkbox functionality in jQuery fails to work properly after initial selection

Every time I click on the checkbox it seems to activate, but then when I try clicking on it again, nothing happens and the checkboxSelected class remains unchanged. Here is the HTML markup: <div class="galleryMenu-center"> <div ...

What are some ways to create responsive elements using Bootstrap?

I'm looking for assistance in using bootstrap to divide a screen into 8 responsive parts (2 at the top, 2 in the middle, and 2 at the bottom). Can anyone help me with this? ...

Tips for creating a mobile-friendly responsive table

I need help with making my table responsive in mobile view. Can someone provide guidance on how to achieve this? Feel free to ask if you have any questions related to my issue. tabel.html I am currently using the Bootstrap framework to create the table ...

Execution of the PHP code within the div element with the id 'upload' is not working properly when trying to use xhr.open("POST", $id("upload").action, true)

Within my .js file, I came across the following line: xhr.open("POST", $id("upload").action, true); xhr.setRequestHeader("X_FILENAME", file.name); xhr.send(file); In the index.php file, there is a form structured like this: <form id="upload" action=" ...

Using Jquery to retrieve the data-id attribute value from the <li> element

Seeking assistance on how to retrieve the value of (data-id=64) when clicking on a specific li-item within a tree structure. The tree consists of 5 list items, each with subchilds. Currently, I am able to obtain the (data-uid) of the first li, but I'm ...

Initiating the click event on a designated element

I'm working on a grid of team members represented by figures with figcaptions. I want to be able to trigger a click function only for the specific figure that has been clicked, rather than applying the function to all figures at once. Here is an exam ...

Designing a horizontal slide banner with enhanced functionality

I am working on displaying a vertical banner that slides out horizontally from the right side of the screen when the user clicks on the open button/div, and also has the ability to close it. The basic design concept is illustrated in the sample image below ...

Tips for creating a cohesive group of HTML elements within an editable area

Imagine having a contenteditable area with some existing content: <div contenteditable="true"> <p>first paragraph</p> <p> <img width='63' src='https://developer.cdn.mozilla.net/media/img/mdn-logo-s ...

Display the importance of utilizing Bootstrap 4's range input feature

Is there a way to display the value of a range input in Bootstrap without using Javascript? I found this tutorial but it doesn't show how to do it: https://getbootstrap.com/docs/4.1/components/forms/#range-inputs <div class="container"> < ...

Is it possible to recognize when the mouse button is held down and the cursor is outside the viewport by using mouseleave detection?

Is there a way to detect when a user moves the mouse outside of the view-port, even if they are holding down the mouse button (for example, if the mouse is on the browser address bar)? In the code below, I am currently using mouseout and mouseleave to det ...

Smooth-scrolling feature with touch interaction available in the scrollbar extension

Anyone here aware of a high-quality jQuery or CSS plugin for scrollbars that supports touch functionality and smooth easing? I've been on the lookout for one, but haven't had any luck so far. Even if it comes with a price tag, I'm interested ...

Eliminating the gray background using CSS

How can I remove the gray background that automatically appears in my CSS header? .header { padding: 60px; margin: 20px auto auto auto; width: 1400px; border-radius: 10px; text-align: center; background: # ...

Stop animation on mobile devices by modifying the CSS file

Using jQuery, I added an animation class to a div on my webpage. The animation.css file has been included as well. The class animated slideInLeft is currently in use. My question is whether it is possible to disable this class for mobile devices in order ...

The PHP navigation is being obscured by the image gallery

I have implemented a PHP navigation system for my website using the code below: * { margin:0; padding:0; list-style:none; text-decoration:none; } img { position: absolute; top: 10px; left: 40%; } ul#navi { float:left; background:#31 ...

Is there a way to have a tooltip expand beyond the boundaries of its table cell?

I'm having trouble with a Tooltip issue. When I hover over the row, the tooltip for icons appears cut off from the top. This only seems to happen in the 1st row of the table, while it looks fine in all other rows. Please refer to the attached image fo ...

What can I do to prevent the text from covering the icon?

My dilemma involves an HTML input alongside a Font Awesome icon. I'm striving to find a way to avoid restricting the amount of text a user can input while ensuring that the text doesn't overlap with .fa-comment-o. Any surplus text should simply b ...

Trouble with Loading Bootstrap CSS File

Having some trouble with Bootstrap - I'm following a basic tutorial and everything seems to be working fine, except the CSS file isn't loading properly. I've checked on StackOverflow but couldn't find a solution that worked for me. Both ...

`Implementing Bootstrap grid system within a PHP loop`

I am currently working on a project that involves extracting data from a database and displaying it on an HTML page using Bootstrap grids. The code snippet below was given to me by someone, and I have made a few modifications by adding two tags: and . How ...

Merging Text within the Yii Framework

Can someone explain the process of combining strings in this code, specifically for first_name and last_name? Thank you in advance for your assistance. <?php /* @var $this AuthassignmentController */ /* @var $data Authassignment */ $datamodel = (Memb ...