Form Placeholder Labels

Developer
Size
3,824 Kb
Views
8,096

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 Previews

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());
});
Form Placeholder Labels - Script Codes
Form Placeholder Labels - Script Codes
Home Page Home
Developer Assaf Gelber
Username agelber
Uploaded January 03, 2023
Rating 4.5
Size 3,824 Kb
Views 8,096
Do you need developer help for Form Placeholder Labels?

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!

Assaf Gelber (agelber) Script Codes
Create amazing love letters with AI!

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!