Last active
August 29, 2015 14:16
-
-
Save thyagorafaell/2d71523f26635fe9c830 to your computer and use it in GitHub Desktop.
Custom input file uploader
This file contains hidden or 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
| .custom-file-uploader { opacity: 0; } | |
| .custom-uploader-component { | |
| cursor: pointer; | |
| margin-top: -52px !important; | |
| padding-top: 10px; | |
| border-radius: 4px; | |
| /*border: 1px solid #ffffff;*/ | |
| border: 1px solid rgba(255, 255, 255, 0.3); | |
| height: 52px; | |
| width: 100%; | |
| text-align: left; | |
| } | |
| .custom-uploader-button { | |
| margin-left: 12px; | |
| background-color: #ffffff; | |
| color: #e44c65 !important; | |
| border-radius: 4px; | |
| padding: 0px 20px; | |
| -webkit-transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out, box-shadow 0.2s ease-in-out; | |
| -moz-transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out, box-shadow 0.2s ease-in-out; | |
| -ms-transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out, box-shadow 0.2s ease-in-out; | |
| -o-transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out, box-shadow 0.2s ease-in-out; | |
| transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out, box-shadow 0.2s ease-in-out; | |
| } | |
| .custom-uploader-component label { | |
| display: inline-block; | |
| vertical-align: top; | |
| } | |
| .custom-file-uploader:hover + .custom-uploader-component .custom-uploader-button { | |
| background-color: rgba(255, 255, 255, 0.075) !important; | |
| box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5) !important; | |
| color: #ffffff !important; | |
| } | |
| .custom-uploader-bar { | |
| color: rgba(255, 255, 255, 0.75); | |
| font-family: "Roboto", Helvetica, sans-serif; | |
| max-width: 250px; | |
| white-space: nowrap; | |
| overflow: hidden; | |
| text-overflow: ellipsis; | |
| font-weight: 100; | |
| line-height: 1.75em; | |
| margin-top: 2px; | |
| } |
This file contains hidden or 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
| <input id="arquivo" class="custom-file-uploader" type="file" > | |
| <div class="custom-uploader-component"> | |
| <label for="arquivo" class="custom-uploader-button" tabindex="-1">Escolher arquivo</label> | |
| <label for="arquivo" class="custom-uploader-bar" tabindex="-1">Nenhum arquivo selecionado</label> | |
| </div> |
This file contains hidden or 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
| $(document).on('change', '.custom-file-uploader', function() { | |
| var file = $(this.val().split('\\'); | |
| $(this).parent().find('custom-uploader-bar').html(file[file.length - 1]); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment