Created
January 28, 2017 18:41
-
-
Save rhuanbarreto/2a5d467da3753915d50eddc9db5e0a3c to your computer and use it in GitHub Desktop.
Floating Labels for BootSwatch Paper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('.form-control').on('focus blur', function (e) { | |
$(this).parents('.form-group').toggleClass('focused', (e.type === 'focus' || this.value.length > 0)); | |
}).trigger('blur'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.form-group { | |
display: flex; | |
height: 55px; | |
} | |
.control-label { | |
font-size: 16px; | |
font-weight: 400; | |
opacity: 0.4; | |
pointer-events: none; | |
position: absolute; | |
transform: translate3d(0, 22px, 0) scale(1); | |
transform-origin: left top; | |
transition: 240ms; | |
} | |
.form-group.focused .control-label { | |
opacity: 1; | |
transform: scale(0.75); | |
} | |
.form-control { | |
align-self: flex-end; | |
} | |
.form-control::-webkit-input-placeholder { | |
color: transparent; | |
transition: 240ms; | |
} | |
.form-control:focus::-webkit-input-placeholder { | |
transition: none; | |
} | |
.form-group.focused .form-control::-webkit-input-placeholder { | |
color: #bbb; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment