LOADING...

Preview

Pen ID
Unlock Campus Themeforest adv

 

Code
CSS
html {
  background-color: #FAFAFF;
}

body {
  width: 600px;
  margin: auto;
  padding: 60px;
}

label {
  position: relative;
  display: block;
  margin-bottom: 15px;
  font-size: 12px;
  color: #DA4167;
  white-space: nowrap;
}

.label-text,
.placeholder {
  display: inline-block;
  color: inherit;
}

.label {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  line-height: 2;
  display: inline-block;
  font-size: 18px;
  cursor: pointer;
}

.label-text {
  position: relative;
  top: 0;
  margin-top: -100%;
  margin-right: 5px;
  transform-origin: left top;
  transform: scale(1);
  transition: transform 0.5s ease, top 0.5s ease, color 0.5s ease;
}

.placeholder {
  position: absolute;
  display: inline-block;
  width: 100%;
  opacity: 1;
  transition: transform 0.5s ease, opacity 0.1s ease;
  white-space: nowrap;
}

input {
  /* &:disabled
   * color: $input-text-color-disabled
   * opacity: $input-opacity-disabled
   * background-color: transparent
   * cursor: not-allowed */
}
input[type="text"], input[type="textarea"] {
  display: block;
  width: 100%;
  margin: 0;
  border: 0 none;
  padding-top: 5px;
  padding-bottom: 5px;
  font-size: 18px;
  color: #DA4167;
  line-height: 1.3;
  background-color: transparent;
}
input:focus {
  outline: none;
}
input[type="textarea"] {
  min-width: 100%;
}

.underline {
  position: relative;
  display: block;
  height: 2px;
  margin-top: -1px;
  overflow: hidden;
}
.underline:before {
  content: "";
  height: 1px;
  display: block;
  background-color: #DA4167;
}
.underline:after {
  content: "";
  display: block;
  position: absolute;
  top: 0;
  right: 100%;
  width: 100%;
  height: 1px;
  background-color: #6d152b;
  transform: translateX(0%);
  transition: transform 0.3s ease 0.2s;
}

/* input:disabled + .underline:before
 * background: $input-text-color-disabled
 * background: linear-gradient(to right, $input-text-color-disabled 0%, $input-text-color-disabled 33%, #fff 33%, #fff 100%)
 * background-size: 3px 100%
 * background-repeat: repeat-x
 * opacity: $input-opacity-disabled */
.underline-inner {
  position: absolute;
  top: 0;
  height: 1px;
  width: 100%;
  transform-origin: center 0;
  transition: transform 0.4s ease, opacity 0s ease 0.3s;
  opacity: 0;
  background-color: #6d152b;
}

.focus .label-text {
  color: #6d152b;
  transform: scale(0.6) translateY(-15px);
}
.focus .placeholder {
  opacity: 0.7;
  transform: translateX(-100%);
}
.focus .underline:after {
  height: 1px;
  background-color: #6d152b;
  transform: translateX(100%);
  transition: transform 0.5s ease;
}
.focus .underline-inner {
  transform: scaleY(2);
  transition: transform 0.4s ease 0.2s, opacity 0s ease 0.3s;
  opacity: 1;
}

.has-content .placeholder {
  opacity: 0;
}

button {
  display: inline-block;
  margin: 0;
  padding: 10px 15px;
  border: 1px solid #DA4167;
  border-radius: 0;
  font-size: 12px;
  color: #DA4167;
  background-color: transparent;
  text-transform: uppercase;
  line-height: 1;
  cursor: pointer;
  transition: color 0.6s ease, border-color 0.6s ease, box-shadow 0.6s ease;
}
button:focus, button:hover {
  outline: none;
  color: #971e3c;
  border-color: #971e3c;
  background-color: #fff;
  box-shadow: 0px 0px 11px 1px rgba(218, 65, 103, 0.4);
}
JS
$(function(){
    $.each($('.js-input-group'), function(){
        var input = new inputHandler($(this));
    });
});

function inputHandler($container){
    this._$inputContainer = $container;
    this._$input = this._$inputContainer.find('input');

    // add event watchers
    this._handleFocus();
    this._handleBlur();
    this._valueHandler();
}

inputHandler.prototype._handleFocus = function(){
    var that = this;
    this._$input.on('focus', function(){
        that._$inputContainer.addClass('focus');
    });
}

inputHandler.prototype._handleBlur = function(){
    var that = this;
    this._$input.on('blur', function(){
        if(!that._inputHasValue) {
            that._$inputContainer.removeClass('focus');
        }
    });
}

inputHandler.prototype._valueHandler = function(){
    var that = this;
    this._$input.on('keyup', function(){
        if(that._$input.val()){
            that._inputHasValue = true;
            that._$inputContainer.addClass('has-content');
        } else{
            that._inputHasValue = false
            that._$inputContainer.removeClass('has-content');
        }        
    });
}
Term
Sat, 04/14/2018 - 20:42

Related Codes

Pen ID
Pen ID
Pen ID
Square Adv