Form Placeholder Labels
How do I make an form placeholder labels?
Form placeholders that turn into labels when typing in the field. What is a form placeholder labels? How do you make a form placeholder labels? This script and codes were developed by Assaf Gelber on 03 January 2023, Tuesday.
Form Placeholder Labels - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Form Placeholder Labels</title> <script src="https://s.codepen.io/assets/libs/modernizr.js" type="text/javascript"></script> <style> /* NOTE: The styles were added inline because Prefixfree needs access to your styles and they must be inlined if they are on local disk! */ * { box-sizing: border-box;
}
.form { width: 320px; margin: 30px auto; font-family: Helvetica, Arial, sans-serif; font-size: 16px; transform: translateZ(0);
}
.form .field { position: relative; margin-bottom: 10px; height: 40px;
}
.form .field .placeholder-label { position: absolute; top: 14px; left: 12px; font-weight: 300; color: #aaa; cursor: text; z-index: 200; transition: all 0.25s;
}
.form .field .placeholder-label:after { content: ":"; opacity: 0; color: #333; transition: all 0.25s;
}
.form .field .placeholder-input { position: absolute; width: 100%; padding: 10px; border-radius: 10px; border: 1px solid #aaa; font-size: 16px; z-index: 100; transition: all 0.25s;
}
.form .field .placeholder-input:focus, .form .field .placeholder-input.not-empty { margin-left: 100px; width: 220px; outline: none;
}
.form .field .placeholder-input:focus + .placeholder-label, .form .field .placeholder-input.not-empty + .placeholder-label { color: #333; cursor: default;
}
.form .field .placeholder-input:focus + .placeholder-label:after, .form .field .placeholder-input.not-empty + .placeholder-label:after { opacity: 1;
}
body { font-family: Helvetica, Arial, sans-serif; font-weight: 300;
}
h1 { margin-top: 50px; font-weight: 300; color: #333; text-align: center;
}
.explanation { width: 500px; margin: 0 auto; line-height: 1.5; text-align: center;
} </style> <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
</head>
<body> <h1>Form Placeholder Labels</h1>
<p class='explanation'> Try typing in the form elements to see the placeholder elegantly turning into a label, helping you remember what the field is for.
</p>
<div class='form'> <div class='field'> <input class='placeholder-input' id='email' type='text'> <label class='placeholder-label' for='email'>Email</label> </div> <div class='field'> <input class='placeholder-input' id='password' type='password'> <label class='placeholder-label' for='password'>Password</label> </div>
</div> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Form Placeholder Labels - Script Codes CSS Codes
* { box-sizing: border-box;
}
.form { width: 320px; margin: 30px auto; font-family: Helvetica, Arial, sans-serif; font-size: 16px; transform: translateZ(0);
}
.form .field { position: relative; margin-bottom: 10px; height: 40px;
}
.form .field .placeholder-label { position: absolute; top: 14px; left: 12px; font-weight: 300; color: #aaa; cursor: text; z-index: 200; transition: all 0.25s;
}
.form .field .placeholder-label:after { content: ":"; opacity: 0; color: #333; transition: all 0.25s;
}
.form .field .placeholder-input { position: absolute; width: 100%; padding: 10px; border-radius: 10px; border: 1px solid #aaa; font-size: 16px; z-index: 100; transition: all 0.25s;
}
.form .field .placeholder-input:focus, .form .field .placeholder-input.not-empty { margin-left: 100px; width: 220px; outline: none;
}
.form .field .placeholder-input:focus + .placeholder-label, .form .field .placeholder-input.not-empty + .placeholder-label { color: #333; cursor: default;
}
.form .field .placeholder-input:focus + .placeholder-label:after, .form .field .placeholder-input.not-empty + .placeholder-label:after { opacity: 1;
}
body { font-family: Helvetica, Arial, sans-serif; font-weight: 300;
}
h1 { margin-top: 50px; font-weight: 300; color: #333; text-align: center;
}
.explanation { width: 500px; margin: 0 auto; line-height: 1.5; text-align: center;
}
Form Placeholder Labels - Script Codes JS Codes
$(".placeholder-input").on("blur", function() { $(this).toggleClass("not-empty", !!$(this).val());
});
Developer | Assaf Gelber |
Username | agelber |
Uploaded | January 03, 2023 |
Rating | 4.5 |
Size | 3,824 Kb |
Views | 8,096 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Translate Demo | 3,188 Kb |
Skew Demo | 3,209 Kb |
Posting Animation | 4,524 Kb |
CSS Only Single-Element 3D Cuboid | 2,913 Kb |
Animation Demo | 3,031 Kb |
Rotate Demo | 3,061 Kb |
Perspective Demo | 3,143 Kb |
Origin Demo | 3,523 Kb |
TranslateZ Demo | 3,176 Kb |
Perspective Origin Demo | 3,614 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Perforated foil | 0x04 | 2,617 Kb |
Multi-step GSAP animation | Acacheung | 2,668 Kb |
HEXAGON | Aurumlux | 1,684 Kb |
Under construction | GhostRider | 1,642 Kb |
A Pen by Tosh | Panev | 2,586 Kb |
Pattern lab logo | TimPietrusky | 3,666 Kb |
Next Word Predictor | Rfalor | 2,776 Kb |
Speech bubbles | Something | 1,547 Kb |
The Fly | GianlucaGuarini | 3,405 Kb |
Simple, flat contact form | Zeaklous | 2,719 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!