Innovative Floating Labels in Javascript and CSS

Something strange is happening and I can't pinpoint whether it's a javascript or css issue. Check out this jSFiddle for context. If you type in the input box and the label doesn't appear, delete the text and try typing it again...odd right?

I have a form that can be viewed either directly or in an iFrame. I'm using jvfloat.js on the inputs to create floating labels with the placeholder values.

$(document).ready( function() {
   $('input').jvfloat();
});

The results vary across browsers (current versions) and also when viewed within an iFrame or not.

Chrome

In IFrame:

Typing in text field doesn't show the label. The "activeLabel" class is added successfully when inspected, but the label doesn't seem to display. It seems like there might be an issue with a CSS transform preventing the label from moving up behind the input field.

Outside IFrame:

Works as expected.

Firefox

In IFrame / Outside IFrame:

Works as expected.

I haven't tested it on other browsers yet. Every now and then, the labels don't work and I can't consistently replicate the issue.

In the jsFiddle, do you notice any major JavaScript or CSS problems that could be causing this unusual behavior?

Answer №1

The issue lies within the CSS.

You've included display, visibility, and opacity to control the visibility of your floating placeholder. This is unnecessary complexity; you can achieve the desired effect with just one of these properties. I recommend sticking with opacity as it serves the purpose effectively.

I have eliminated the use of visibility in the code, and now it functions correctly:

http://jsfiddle.net/njjZr/3/

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

Is innerHTML incapable of executing JavaScript code?

Experimenting with a new technique where I divide my code into separate files to create multiple HTML pages instead of one large one. Using ajax to load them and then setting the content as innerHTML to a parent div results in clean code that works well in ...

Encountered an error with the Vue Slick Carousel that states "Uncaught (in promise) TypeError: this.$

Hey there! I'm trying to incorporate a carousel using Vue Slick Carousel in my Vue component. Here's what I have so far: <vue-slick-carousel v-if="groupOne && groupOne.length > 0" v-bind="settings& ...

Tips for positioning an element so that it remains anchored to the content it is placed within

Hey Everyone! I'm struggling a bit with how to position the h2 headings in my code so that they stay fixed in the top right corner of the box while moving along with the rest of the contenthttps://i.stack.imgur.com/OOVaA.png%60 What I'm attempt ...

The clip-path in Div: Css is malfunctioning and not displaying correctly

I am trying to create a chat bubble using CSS with rounded corners and a bottom-right arrow. However, I am having trouble getting the arrow to display correctly. https://i.stack.imgur.com/gVXOV.png The CSS styling for the chat bubble is as follows: ...

Validating HTML using EJS templates set as "text/template" elements

What is the general consensus on HTML validation when utilizing a framework such as Backbone or Meteor and generating views in the client from EJS templates? An issue arises with the fact that name is not considered an official attribute for a <script& ...

The character count displayed in an ASP.NET text box may not match the character count of the text box on the

I've implemented a JavaScript function to show users the remaining character count on a page. However, when I validate the length server-side before inserting it into a database column, the count appears to be different. After researching online, it ...

Interested in using jQuery to trigger the f12 key press?

In my current project, I have successfully disabled the f12 and right click using jQuery. Here is the code snippet: $(document).keydown(function(event){ if(event.keyCode==123){ return false; } else if(event.ctrlKey && event.shiftKey && ...

Using video instead of static slides in HTML5

I am interested in adding a video background with text overlay on my website, similar to what can be seen here: Although I understand it involves CSS, I am struggling to achieve the desired effect. Here is the code snippet I have been using: video#bgvid ...

What is the best way to extract basic information from a JSON object?

What is the best way to retrieve the weight value from this specific object? var prescription = "{'type':'" + $('#medi-type option:selected').val() +"',"+ "'weight':" + $('#weight').val() +","+ ...

What steps can be taken to stop the update function from inserting data into MongoDB from a Meteor application

Within my Meteor method, I have implemented a function to check for existing documents. If the document is not found, it gets inserted into the database. However, if it is found during a second attempt, the document is updated and a new one is also inserte ...

Implementing Highcharts in AngularJS with dynamic variables directly in the code (leveraging Pablojim's Highchart-ng library)

Currently, I am utilizing the Highchart charting library in conjunction with AngularJS by employing Pablojim's 'Highchart-ng' module. The setup is correct, and the following code functions as expected: <highchart config="{ type : ...

What is the best way to implement a callback in JavaScript (Node) in order to ensure that an asynchronous function finishes before moving on

I have a function called translateCommand(command) that uses a Translate package from npm to translate some text into a different language. The issue arises because the translate function provided by that package is asynchronous, causing the translateComma ...

How can I use Python Selenium to replicate the styles of elements in Chrome?

Looking at this image, we can manually extract styles using copy > copy styles from Chrome. But is there a way to achieve this using Selenium? https://i.sstatic.net/3XzsT.png Although this guide explains how to obtain the CSS value of a specific eleme ...

Enhancing Graphics with Anti Aliasing in Three.js and WebGL

While spinning my model with an orbiter, I am experiencing some issues with anti-aliasing. Currently, I am using the following renderer: renderer = new THREE.WebGLRenderer({ preserveDrawingBuffer: true, antialias: true }) ...

What is causing the z-index: -1 to not function properly in this particular case?

I'm struggling to get the <i> element to display below the anchor in the stacking order. Any suggestions on how to achieve this? a.button { background-color: gray; border-radius: 5px; color: rgb(247, 247, 247); display: inline-block; ...

Creating a way for a Node and React application to share classes

I am in the process of developing a Node and React application, both implemented using TypeScript. The directory structure of my project is illustrated below: https://i.sstatic.net/914A1.png My query: Given that I am utilizing the same programming langu ...

Preventing the generation of div tags with Thymeleaf's th:each functionality

<div class="question" th:each="question : ${questions}"> <h2 id="question" class="description" th:text="${question.description}">Question goes here</h2> <div id= ...

Evaluating the layout of a webpage with each new code update

I'm currently in search of a testing framework to evaluate the frontend and design aspects of my application. We are developing an Angular application and utilizing Protractor for end-to-end tests, but I am curious about how to test the visual design ...

What is the best way to align a GIF and two rows of text within a container div?

Check out my JSFiddle below: In this fiddle, there is an image sized 32 by 32 on the left side and two lines of text on the right. I need help aligning the center of the gif and the text with the middle of the enclosing frame. I've tried adjusting t ...

Add the item and increase its value within an array using AngularJS

http://plnkr.co/edit/NDTgTaTO1xT7bLS1FALN?p=preview <button ng-click="addRow()">add row</button> <div ng-repeat="row in rows"> <input type="text" placeholder="name"><input type="tel" placeholder="tel"> </div> I am cur ...