"Move placeholder to top while focus input"
Bootstrap 4.1.1 Snippet by thangytp

<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <!------ Include the above in your HEAD tag ----------> <div> <input type="text" class="inputText" required/> <span class="floating-label">Your email address</span> </div>
input:focus ~ .floating-label, input:not(:focus):valid ~ .floating-label{ top: 2px; bottom: 16px; left: 12px; font-size: 11px; opacity: 1; } .inputText { font-size: 14px; width: 200px; height: 50px; } .floating-label { position: absolute; pointer-events: none; left: 20px; top: 10px; transition: 0.2s ease all; }

Related: See More


Questions / Comments: