Advertisement
afsarwebdev

Float Label in Form

Sep 21st, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. //Html
  2. <form action="">
  3. <div class="form-group single-input">
  4. <input type="text" class="form-control float-label" required>
  5. <span class="highlight"></span>
  6. <label for="" class="">Your Name</label>
  7. </div>
  8. </form>
  9.  
  10. //CSS
  11. //Style for the float label
  12. input {
  13. position:relative;
  14. }
  15. label {
  16. color: #e1e1e1;
  17. font-size: 0.722em;
  18. font-weight: normal;
  19. position: absolute;
  20. pointer-events: none;
  21. left: 5px;
  22. top: 10px;
  23. @extend .transition;
  24. }
  25.  
  26. .float-label:focus ~ label, .float-label:valid ~ label {
  27. top: -20px;
  28. font-size: 0.722em;
  29. color: #fff;
  30.  
  31. }
  32.  
  33. /* active state */
  34. .float-label:focus ~ .bar:before, .float-label:focus ~ .bar:after {
  35. width:50%;
  36. }
  37.  
  38. .float-label:focus ~ .highlight {
  39. -webkit-animation:inputHighlighter 0.3s ease;
  40. -moz-animation:inputHighlighter 0.3s ease;
  41. animation:inputHighlighter 0.3s ease;
  42. }
  43.  
  44. @-webkit-keyframes inputHighlighter {
  45. from { background:#5264AE; }
  46. to { width:0; background:transparent; }
  47. }
  48. @-moz-keyframes inputHighlighter {
  49. from { background:#5264AE; }
  50. to { width:0; background:transparent; }
  51. }
  52. @keyframes inputHighlighter {
  53. from { background:#5264AE; }
  54. to { width:0; background:transparent; }
  55. }
  56.  
  57. // End style for float label
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement