Skip to content

Instantly share code, notes, and snippets.

@billyxs
Last active September 24, 2015 15:44
Show Gist options
  • Save billyxs/90f08549b242963c6c30 to your computer and use it in GitHub Desktop.
Save billyxs/90f08549b242963c6c30 to your computer and use it in GitHub Desktop.
Styled file input button with accesibility
<!-- 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