Last active
October 28, 2015 00:32
-
-
Save ryanve/db138eac14a5b62f5666 to your computer and use it in GitHub Desktop.
CSS module for semantic inline [type=file] inputs
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
| .browse { | |
| display: inline; | |
| font-size: inherit; | |
| } | |
| .browse__input { | |
| display: inline-block; | |
| position: absolute; | |
| @include px-rem(padding, .1); | |
| @include px-rem(margin, 0, -.5); | |
| height: 0; | |
| width: 0; | |
| overflow: hidden; | |
| &::before { | |
| // hack to respect the `cursor` style | |
| white-space: pre; | |
| content: " "; | |
| display: block; | |
| } | |
| } | |
| // enabled or disabled | |
| .browse__input[class] { | |
| opacity: .0001; | |
| } | |
| .browse__label { | |
| display: inline-block; | |
| } | |
| .browse__input:enabled, | |
| .browse__input:enabled + .browse__label { | |
| cursor: pointer; | |
| } |
Author
Author
alternate markup
<fieldset class="browse">
<input id="browse" class="browse__input" type="file" tabindex="0">
<label for="browse" class="browse__label button">Browse</label>
</fieldset>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
example markup