Last active
September 24, 2015 15:44
-
-
Save billyxs/90f08549b242963c6c30 to your computer and use it in GitHub Desktop.
Styled file input button with accesibility
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
<!-- Solution as found in - http://tympanus.net/codrops/2015/09/15/styling-customizing-file-inputs-smart-way/ --> | |
<style> | |
.inputfile { | |
width: 0.1px; | |
height: 0.1px; | |
opacity: 0; | |
overflow: hidden; | |
position: absolute; | |
z-index: -1; | |
} | |
.inputfile + label { | |
font-size: 1.25em; | |
font-weight: 700; | |
color: white; | |
background-color: black; | |
display: inline-block; | |
cursor: pointer; /* "hand" cursor */ | |
} | |
.inputfile:focus + label, | |
.inputfile + label:hover { | |
background-color: red; | |
} | |
</style> | |
<input type="file" name="file" id="file" class="inputfile" /> | |
<label for="file">Choose a file</label> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment