├── float-label-css.gif ├── koala-config.json ├── package.json ├── scss ├── _mixins.scss └── float-label.scss ├── LICENSE ├── dist ├── float-label.min.css └── float-label.css ├── index.html └── README.md /float-label-css.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anydigital/float-label-css/HEAD/float-label-css.gif -------------------------------------------------------------------------------- /koala-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "mappings": [ 3 | { 4 | "src": "scss", 5 | "dest": "dist" 6 | } 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "float-label-css", 3 | "version": "1.0.2", 4 | "description": "Bulletproof CSS-only implementation of Float Label pattern with automatic fallback for ANY non-supporting browser.", 5 | "repository": { 6 | "type": "git", 7 | "url": "https://github.com/tonystar/float-label-css.git" 8 | }, 9 | "keywords": [ 10 | "float-label", 11 | "css-only" 12 | ], 13 | "author": "Anton Staroverov (https://tonystar.me)", 14 | "license": "MIT", 15 | "bugs": { 16 | "url": "https://github.com/tonystar/float-label-css/issues" 17 | }, 18 | "homepage": "https://github.com/tonystar/float-label-css#readme" 19 | } 20 | -------------------------------------------------------------------------------- /scss/_mixins.scss: -------------------------------------------------------------------------------- 1 | @mixin float-label-container { 2 | display: block; 3 | position: relative; 4 | } 5 | 6 | @mixin float-label { 7 | label, > span { 8 | position: absolute; 9 | left: 0; 10 | top: 0; 11 | cursor: text; 12 | font-size: 75%; 13 | opacity: 1; 14 | transition: all .2s; 15 | @content; 16 | } 17 | } 18 | 19 | @mixin float-label-input { 20 | &::placeholder { 21 | opacity: 1; 22 | transition: all .2s; 23 | } 24 | &:placeholder-shown:not(:focus)::placeholder { 25 | opacity: 0; 26 | } 27 | } 28 | 29 | @mixin float-label-scaled { 30 | &:placeholder-shown:not(:focus) + * { 31 | font-size: 150%; 32 | opacity: .5; 33 | @content; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /scss/float-label.scss: -------------------------------------------------------------------------------- 1 | @import "mixins"; 2 | 3 | .has-float-label { 4 | @include float-label-container; 5 | 6 | @include float-label; 7 | 8 | select { 9 | -webkit-appearance: none; 10 | -moz-appearance: none; 11 | appearance: none; 12 | } 13 | 14 | textarea { 15 | width: 100%; 16 | } 17 | 18 | input, select, textarea { 19 | @include float-label-input; 20 | font-size: inherit; 21 | padding-top: 1em; 22 | margin-bottom: 2px; 23 | border: 0; 24 | border-radius: 0; 25 | border-bottom: 2px solid rgba(0,0,0,.1); 26 | 27 | @include float-label-scaled { 28 | top: .25em; 29 | } 30 | 31 | &:focus { 32 | outline: none; 33 | border-color: rgba(0,0,0,.5); 34 | } 35 | } 36 | 37 | select { 38 | padding-right: 1em; 39 | background: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 4 5'%3E%3Cpath fill='%23333' d='M2 0L0 2h4zm0 5L0 3h4z'/%3E%3C/svg%3E") no-repeat right .5em bottom .25em; 40 | background-size: 8px 10px; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Anton Staroverov 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /dist/float-label.min.css: -------------------------------------------------------------------------------- 1 | .has-float-label{display:block;position:relative}.has-float-label label,.has-float-label>span{position:absolute;left:0;top:0;cursor:text;font-size:75%;opacity:1;-webkit-transition:all .2s;transition:all .2s}.has-float-label select{-webkit-appearance:none;-moz-appearance:none;appearance:none}.has-float-label textarea{width:100%}.has-float-label input,.has-float-label select,.has-float-label textarea{font-size:inherit;padding-top:1em;margin-bottom:2px;border:0;border-radius:0;border-bottom:2px solid rgba(0,0,0,.1)}.has-float-label input::-webkit-input-placeholder,.has-float-label select::-webkit-input-placeholder,.has-float-label textarea::-webkit-input-placeholder{opacity:1;-webkit-transition:all .2s;transition:all .2s}.has-float-label input::-moz-placeholder,.has-float-label select::-moz-placeholder,.has-float-label textarea::-moz-placeholder{opacity:1;transition:all .2s}.has-float-label input:-ms-input-placeholder,.has-float-label select:-ms-input-placeholder,.has-float-label textarea:-ms-input-placeholder{opacity:1;transition:all .2s}.has-float-label input::placeholder,.has-float-label select::placeholder,.has-float-label textarea::placeholder{opacity:1;-webkit-transition:all .2s;transition:all .2s}.has-float-label input:placeholder-shown:not(:focus)::-webkit-input-placeholder,.has-float-label select:placeholder-shown:not(:focus)::-webkit-input-placeholder,.has-float-label textarea:placeholder-shown:not(:focus)::-webkit-input-placeholder{opacity:0}.has-float-label input:placeholder-shown:not(:focus)::-moz-placeholder,.has-float-label select:placeholder-shown:not(:focus)::-moz-placeholder,.has-float-label textarea:placeholder-shown:not(:focus)::-moz-placeholder{opacity:0}.has-float-label input:placeholder-shown:not(:focus):-ms-input-placeholder,.has-float-label select:placeholder-shown:not(:focus):-ms-input-placeholder,.has-float-label textarea:placeholder-shown:not(:focus):-ms-input-placeholder{opacity:0}.has-float-label input:placeholder-shown:not(:focus)::placeholder,.has-float-label select:placeholder-shown:not(:focus)::placeholder,.has-float-label textarea:placeholder-shown:not(:focus)::placeholder{opacity:0}.has-float-label input:placeholder-shown:not(:focus)+*,.has-float-label select:placeholder-shown:not(:focus)+*,.has-float-label textarea:placeholder-shown:not(:focus)+*{font-size:150%;opacity:.5;top:.25em}.has-float-label input:focus,.has-float-label select:focus,.has-float-label textarea:focus{outline:0;border-color:rgba(0,0,0,.5)}.has-float-label select{padding-right:1em;background:url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 4 5'%3E%3Cpath fill='%23333' d='M2 0L0 2h4zm0 5L0 3h4z'/%3E%3C/svg%3E") no-repeat right .5em bottom .25em;background-size:8px 10px} -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 |