Advertisement
Willcode4cash

Floating field labels

Jul 20th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.32 KB | None | 0 0
  1. <!-- https://jsfiddle.net/WillCode4Cash/6arhkhaw/ -->
  2. <html>
  3. <head>
  4. <link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.css" rel="stylesheet" />
  5. <style>
  6.     @import url('https://fonts.googleapis.com/css?family=Source+Sans+Pro');
  7.     body,
  8.     html {
  9.       font-family: 'Source Sans Pro', sans-serif;
  10.       padding: 50px 25px;
  11.     }
  12.  
  13.     input:focus ~ .floating-label,
  14.     input:not(:focus):valid ~ .floating-label {
  15.       top: 4px;
  16.       bottom: 10px;
  17.       left: 20px;
  18.       font-size: 11px;
  19.       opacity: 1;
  20.     }
  21.  
  22.     .controlContainer {
  23.       position: relative;
  24.     }
  25.  
  26.     .inputText {
  27.       position: absolute;
  28.       font-size: 14px;
  29.       text-transform: uppercase;
  30.       height: 55px;
  31.       padding-left: 20px;
  32.     }
  33.  
  34.     .floating-label {
  35.       position: absolute;
  36.       text-transform: uppercase;
  37.       pointer-events: none;
  38.       left: 20px;
  39.       top: 18px;
  40.       transition: 0.1s ease all;
  41.     }
  42. </style>
  43. <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.js"></script>
  44. <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.js"></script>
  45. <script>
  46. $(document).ready(function(){
  47.  
  48. });
  49. </script>
  50. </head>
  51. <body>
  52. <div class="controlContainer">
  53.   <input type="text" class="inputText form-control" required/>
  54.   <span class="floating-label">Enter your email address</span>
  55. </div>
  56. </body>
  57. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement