White Arrow icon
Back to all Elements

Floating Labels Interaction

A short CSS code for floating labels on a form

For this to work we need a few things:

  1. You need to have a label for each input field. Those needs to be placed as siblings right after the input field.
  2. A short CSS code to handle the input states
  3. On an Email field, you must have a placeholder text (a blank space or transparent text can work great)

<style>
 input:focus~.floating-label,
 input:not(:focus):valid~.floating-label,
 input[type=email]:not(:placeholder-shown)~.floating-label {
   bottom: 35px;
   font-size: 11px;
 }

 .input-text:focus {
   outline: none;
 }
</style>

Copy

Preview:

browser mockup
Share:
Heart icon

Destin's Youtube channel Smarter Every Day is one of my favourite places on the web.

Might also interest you:

3d Video Slider (swiper.js)

Cloneable
CMS
JavaScript

A 3d slider with video items, plays and pauses on click & slide change.

Read more
Blue arrow iconWhite Arrow icon

Webflow Dashboard Workspaces Hack

Webflow UI Hack
Code
CSS

Convert the Workspaces dropdown to an open sidebar with custom order.

Read more
Blue arrow iconWhite Arrow icon

Glossary

Cloneable
JavaScript
CMS

A clonable for creating an Alphabetical glossary

Read more
Blue arrow iconWhite Arrow icon