JSFiddle - React, Tailwind, and code Playground
Custom CSS File Upload Form Control
by Jennifer Perrin
HTML
<div class="custom_file_upload">
<input type="text" class="file" name="file_info" />
<div class="file_upload">
<input type="file" id="file_upload" name="file_upload" />
</div>
</div>
CSS
@import url(http://fonts.googleapis.com/css?family=Raleway);
body {
font-family: 'Raleway', 'Helvetica Neue', sans-serif;
font-size: 13px;
}
div.custom_file_upload {
width: 230px;
height: 20px;
margin: 40px auto;
}
input.file {
width: 150px;
height: 20px;
border: 1px solid #BBB;
border-right: 0;
color: #888;
padding: 5px;
outline: none;
}
div.file_upload {
width: 80px;
height: 24px;
background: #7abcff;
background: -moz-linear-gradient(top, #7abcff 0%, #60abf8 44%, #4096ee 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#7abcff), color-stop(44%,#60abf8), color-stop(100%,#4096ee));
background: -webkit-linear-gradient(top, #7abcff 0%,#60abf8 44%,#4096ee 100%);
background: -o-linear-gradient(top, #7abcff 0%,#60abf8 44%,#4096ee 100%);
background: -ms-linear-gradient(top, #7abcff 0%,#60abf8 44%,#4096ee 100%);
background: linear-gradient(top, #7abcff 0%,#60abf8 44%,#4096ee 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#7abcff', endColorstr='#4096ee',GradientType=0 );
display: inline;
position: absolute;
overflow: hidden;
cursor: pointer;
font-weight: bold;
color: #FFF;
text-align: center;
padding-top: 8px;
}
div.file_upload:before {
content: 'UPLOAD';
position: absolute;
left: 0; right: 0;
text-align: center;
cursor: pointer;
}
div.file_upload input {
position: relative;
height: 30px;
width: 250px;
display: inline;
cursor: pointer;
opacity: 0;
}