Skip to content

Instantly share code, notes, and snippets.

@thyagorafaell
Last active August 29, 2015 14:16
Show Gist options
  • Select an option

  • Save thyagorafaell/2d71523f26635fe9c830 to your computer and use it in GitHub Desktop.

Select an option

Save thyagorafaell/2d71523f26635fe9c830 to your computer and use it in GitHub Desktop.
Custom input file uploader
.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;
}
<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>
$(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