1

Copy the code in the pink box for input fields

Text | Number
Email | Password

Input field example

<div class="float-group">
    <input type="text" class="float-style" id="ex1" onfocus="floatFocus(this)" onblur="floatBlur(this)" />
    <label for="ex1">Input Example</label>
</div>
2

Copy the code in the pink box for textareas

Rows Optional

Textarea example

<div class="float-group textarea">
    <textarea class="float-style" id="ex2" rows="3" onfocus="floatFocus(this)" onblur="floatBlur(this)"></textarea>
    <label for="ex2">Textarea Example</label>
</div>
3

Copy the code in the pink box for dropdowns

Label on top

Select example

<div class="float-group select">
    <label for="ex3">Select Example</label>
    <select class="float-style" id="ex3">
        <option>Option 1</option>
        <option>Option 2</option>
        <option>Option 3</option>
    </select>
</div>
4

Copy the code in the pink box for option fields

Don't forget the label 'for' attribute

Radio example

Is this Awesome

<div class="float-group option">
    <p>Is this Awesome</p>
    <input type="radio" name="default" id="yes">
    <label for="yes">Yes</label>
    <input type="radio" name="default" id="yes2">
    <label for="yes2">Definitely</label>
    <input type="radio" name="default" id="yes3">
    <label for="yes3">YUP!</label>
</div>

Download Zip

Copy Code

:root {
    --input-text-color: #2e2e2e;
    --label-text-color: #707070;

    --disabled-input-text-color: #909090;
    --disabled-label-text-color: #aaa;

    --input-border-color: #e3e3e3;
    --input-border-color-focus: #707070;
}
.float-group {
    width: 100%;
    position: relative;
    margin-bottom: 10px;
}
.float-group .float-style { width: 100% }
.float-group input[type=text].float-style,
.float-group input[type=number].float-style,
.float-group input[type=email].float-style,
.float-group input[type=password].float-style {
    height: 45px;
    background: white;
    border: 1px solid var(--input-border-color);
    position: relative;
    left: 0;
    top: 0;
    z-index: 1;
    font-size: 14px;
    color: var(--input-text-color);
    font-weight: 500;
    outline: none;
    padding: 21px 10px 5px 5px;
}
.float-group input[type=text].float-style:focus,
.float-group input[type=number].float-style:focus,
.float-group input[type=email].float-style:focus,
.float-group input[type=password].float-style:focus,
.float-group textarea.float-style:focus,
.float-group select.float-style:focus {
    border: 1px solid var(--input-border-color-focus);
}
.float-group input[type=text].float-style.active + label,
.float-group input[type=number].float-style.active + label,
.float-group input[type=email].float-style.active + label,
.float-group input[type=password].float-style.active + label,
.float-group textarea.float-style.active + label {
    position: absolute;
    top: 6px;
    left: 6px;
    font-size: 11px;
    z-index: 2;
}
.float-group input[type=text]:disabled {
    background: #F3F3F4;
    border-color: #F3F3F4;
    color: var(--disabled-input-text-color);
    cursor: not-allowed;
}
.float-group input[type=text]:disabled + label {
    color: var(--disabled-label-text-color);
    cursor: not-allowed;
}
.float-group label {
    position: absolute;
    top: 14px;
    left: 6px;
    font-size: 14px;
    color: var(--label-text-color);
    z-index: 2;
    -webkit-transition: all 0.18s ease;
    -moz-transition: all 0.18s ease;
    -o-transition: all 0.18s ease;
    transition: all 0.18s ease;
}
.float-group button.search {
    border: 0;
    background: transparent;
    box-shadow: none;
    position: absolute;
    right: 7px;
    top: 11px;
    color: #4E5255;
    z-index: 3;
    cursor: pointer;
    padding: 0;
}
.float-group.textarea label {
    position: absolute;
}
.float-group.textarea textarea {
    border: 1px solid var(--input-border-color);
    outline: none;
    padding: 21px 6px 6px;
    color: var(--input-text-color);
    font-weight: 500;
    font-size: 14px;
    top: 0;
    position: relative;
}
.float-group.textarea textarea:disabled {
    background: #F3F3F4;
    border-color: #F3F3F4;
    color: #95989A;
    cursor: not-allowed;
}
.float-group.option {
    padding-bottom: 2px;
}
.float-group.option input[type=radio],
.float-group.option input[type=checkbox] {
    position: relative;
    top: 2px;
}
.float-group.option p {
    margin-bottom: 8px;
    font-size: 16px;
    color: var(--label-text-color);
}
.float-group.option label {
    color: var(--label-text-color);
    position: relative;
    left: 0;
    top: 1px;
    margin-right: 15px;
    font-size: 14px;
    display: inline-block;
}
.float-group.select label {
    position: relative;
    font-size: 12px;
    line-height: 14px;
    margin-bottom: 3px;
    display: block;
    left: 0;
    top: 0;
    color: var(--label-text-color);
}
.float-group.select .float-style {
    height: 28px;
    width: 100%;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    border-radius: 0;
    border: 1px solid var(--input-border-color);
    font-size: 14px;
    color: var(--input-text-color);
    padding: 0 8px;
    outline: none;
    background: url('https://cdn.augeobiz.com/static/storefront/general/select.svg') white no-repeat top 6px right 5px;
    background-size: 14px 14px;
}
var floats = document.querySelectorAll('.float-style'), i;

document.addEventListener('DOMContentLoaded', function () {
    for (i = 0; i < floats.length; ++i) {
        console.log(floats[i].value);
        if(floats[i].value != '') {
            floatFocus(floats[i]);
        }
    }
}, false);

function floatBlur(input) {
    if(input.value == '') {
        input.classList.remove('active');
    }
}

function floatFocus(input) {
    input.classList.add('active');
}