Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <div class="container" id="form">
  <h2 class="h2">Bootstrap's animated & overlayed form elements</h2>

  <p>
    The base about form elements the structure still the bootstrap structure, with a <code>.form-group</code> composed of a <code>label</code> and a <code>input.form-control</code>.
  </p>

  <div class="panel panel-default showcase">
    <div class="panel-body">
      <div class="form-group">
        <label for="#form-control-1">Example 1</label>
        <input class="form-control" id="form-control-1" type="text">
      </div>
    </div>

    <div class="panel-footer">
      <pre>&lt;div class="form-group"&gt;<br>    &lt;label&gt;Example 1&lt;/label&gt;<br>    &lt;input class="form-control" type="text"&gt;<br>&lt;/div&gt;</pre>
    </div>
  </div>

  <p>
    For using the animated version, just add the variant class <code>.-animated</code> on the <code>.form-group</code> element
  </p>

  <div class="panel panel-default showcase">
    <div class="panel-body">
      <div class="form-group -animated">
        <label for="#form-control-2">Example 2</label>
        <input class="form-control" id="form-control-2" type="text">
      </div>
    </div>

    <div class="panel-footer">
      <pre>&lt;div class="form-group -animated"&gt;<br>    &lt;label&gt;Example 2&lt;/label&gt;<br>    &lt;input class="form-control" type="text"&gt;<br>&lt;/div&gt;</pre>
    </div>
  </div>

  <p>
    To put an global overlay on the focus of the <code>.form-control</code>, use the variant class <code>.-overlayed</code>.
  </p>

  <div class="panel panel-default showcase">
    <div class="panel-body">
      <div class="form-group -overlayed">
        <label for="#form-control-3">Example 3</label>
        <input class="form-control" id="form-control-3" type="text">
      </div>
    </div>

    <div class="panel-footer">
      <pre>&lt;div class="form-group -overlayed"&gt;<br>    &lt;label&gt;Example 3&lt;/label&gt;<br>    &lt;input class="form-control" type="text"&gt;<br>&lt;/div&gt;</pre>
    </div>
  </div>

  <p>
    You can of course use <code>.-animated</code> and <code>.-overlayed</code> on the same element
  </p>

  <div class="panel panel-default showcase">
    <div class="panel-body">
      <div class="form-group -animated -overlayed">
        <label for="#form-control-4">Example 4</label>
        <input class="form-control" id="form-control-4" type="text">
      </div>
    </div>

    <div class="panel-footer">
      <pre>&lt;div class="form-group -animated -overlayed"&gt;<br>    &lt;label&gt;Example 4&lt;/label&gt;<br>    &lt;input class="form-control" type="text"&gt;<br>&lt;/div&gt;</pre>
    </div>
  </div>

  <p>
    If you need to you can add a form-caption that will appear when the input is focused. You need to add a third element into the <code>.form-group</code> with the class code{.form-caption} and then whatever you want into.
  </p>

  <div class="panel panel-default showcase">
    <div class="panel-body">
      <div class="form-group -animated -overlayed">
        <div class="form-caption">Lorem ipsum</div>
        <label for="#form-control-5">Example 5</label>
        <input class="form-control" id="form-control-5" type="text">
      </div>
    </div>

    <div class="panel-footer">
      <pre>&lt;div class="form-group -animated -overlayed"&gt;<br>    &lt;div class="form-caption"&gt;lorem ipsum&lt;/div&gt;<br>    &lt;label&gt;Example 5&lt;/label&gt;<br>    &lt;input class="form-control" type="text"&gt;<br>&lt;/div&gt;</pre>
    </div>
  </div>

  <p>
    You can choose the position of the form-caption (the 4 corner) with the variant classes <code>.-topLeft</code>, <code>.-topRight</code>, <code>.-bottomRight</code>, <code>.-bottomLeft</code>. For Mobile and Tablet (xs and sm viewport), you have the
    choice between 2 position top or bottom with the respective classes <code>-touchTop</code> and <code>-touchBottom</code>
  </p>

  <div class="panel panel-default showcase">
    <div class="panel-body">
      <div class="form-group -animated -overlayed">
        <div class="form-caption -topLeft -touchTop">Lorem ipsum</div>
        <label for="#form-control-61">Example 6.1</label>
        <input class="form-control" id="form-control-61" type="text">
      </div>

      <div class="form-group -animated -overlayed">
        <div class="form-caption -topRight -touchBottom">Lorem ipsum</div>
        <label for="#form-control-62">Example 6.2</label>
        <input class="form-control" id="form-control-62" type="text">
      </div>

      <div class="form-group -animated -overlayed">
        <div class="form-caption -bottomRight -touchTop">Lorem ipsum</div>
        <label for="#form-control-63">Example 6.3</label>
        <input class="form-control" id="form-control-63" type="text">
      </div>

      <div class="form-group -animated -overlayed">
        <div class="form-caption -bottomLeft -touchBottom">Lorem ipsum</div>
        <label for="#form-control-64">Example 6.4</label>
        <input class="form-control" id="form-control-64" type="text">
      </div>
    </div>

    <div class="panel-footer">
      <pre>&lt;div class="form-group -animated -overlayed"&gt;<br>    &lt;div class="form-caption -topLeft"&gt;lorem ipsum&lt;/div&gt;<br>    &lt;label&gt;Example 6.1&lt;/label&gt;<br>    &lt;input class="form-control" type="text"&gt;<br>&lt;/div&gt;</pre>

      <pre>&lt;div class="form-group -animated -overlayed"&gt;<br>    &lt;div class="form-caption -topRight"&gt;lorem ipsum&lt;/div&gt;<br>    &lt;label&gt;Example 6.2&lt;/label&gt;<br>    &lt;input class="form-control" type="text"&gt;<br>&lt;/div&gt;</pre>

      <pre>&lt;div class="form-group -animated -overlayed"&gt;<br>    &lt;div class="form-caption -bottomRight"&gt;lorem ipsum&lt;/div&gt;<br>    &lt;label&gt;Example 6.3&lt;/label&gt;<br>    &lt;input class="form-control" type="text"&gt;<br>&lt;/div&gt;</pre>

      <pre>&lt;div class="form-group -animated -overlayed"&gt;<br>    &lt;div class="form-caption -bottomLeft"&gt;lorem ipsum&lt;/div&gt;<br>    &lt;label&gt;Example 6.4&lt;/label&gt;<br>    &lt;input class="form-control" type="text"&gt;<br>&lt;/div&gt;</pre>
    </div>
  </div>

  <p>
    Works with textarea too !
  </p>

  <div class="panel panel-default showcase">
    <div class="panel-body">
      <div class="form-group -animated -overlayed">
        <div class="form-caption">Lorem ipsum</div>
        <label for="#form-control-7">Example 7</label>
        <textarea class="form-control" id="form-control-7" cols="30" rows="10"></textarea>
      </div>
    </div>

    <div class="panel-footer">
      <pre>&lt;div class="form-group -animated -overlayed"&gt;<br>    &lt;div class="form-caption"&gt;lorem ipsum&lt;/div&gt;<br>    &lt;label&gt;Example 7&lt;/label&gt;<br>    &lt;textarea class="form-control" cols="30" rows="10"&gt;&lt;/textarea&gt;<br>&lt;/div&gt;</pre>
    </div>
  </div>
</div>
            
          
!
            
              @import "bourbon";

$anthracite: #262732;
$blue: #66B0CB;
$green: #7BCC70;

$border-radius-base:        3px;
$border-radius-large:       20px;
$border-radius-small:       1px;

//** `<input>` background color
$input-bg:                       transparent;
//** `<input disabled>` background color

//** Text color for `<input>`s
$input-color:                    $anthracite;
//** `<input>` border color
$input-border:                   $blue;

// TODO: Rename `$input-border-radius` to `$input-border-radius-base` in v4
//** Default `.form-control` border radius
// This has no effect on `<select>`s in some browsers, due to the limited stylability of `<select>`s in CSS.
$input-border-radius:            $border-radius-base;
//** Large `.form-control` border radius
$input-border-radius-large:      $border-radius-large;
//** Small `.form-control` border radius
$input-border-radius-small:      $border-radius-small;

//** Border color for inputs on focus
$input-border-focus:             $blue;

//** Placeholder text color
$input-color-placeholder:        $green;

//** Default `.form-control` height
$input-height-base:              50px;
//** Large `.form-control` height
$input-height-large:             60px;
//** Small `.form-control` height
$input-height-small:             40px;

//** `.form-group` margin
$form-group-margin-bottom:       50px;


//** Border color for textual input addons
$input-group-addon-border-color: $input-border !default;

//** Disabled cursor for form controls and buttons.
$cursor-disabled:                not-allowed !default;
$input-color-placeholder: $green;
$font-size-h6: 18px;

$font-size-base: 14px;
$font-size-large: round(($font-size-base * 1.142857143)); // 16px
$font-size-small: round(($font-size-base * 0.857142857)); // 12px
$input-height-base: 50px;
$zindex-modal: 1050 !default;



$formGroup_paddingTop-_animated: 30px;
$formGroup_transitionDuration: 0.3s;
$formGroup_transitionTimingFunction: ease;
$formControl_borderWidth: 2px;

$formLabel_lineHeight: 19px;
$formLabel_color-_animated: $blue;
$formLabel_color-_animated-_active: $input-color-placeholder;


// Corner info
// ===========

$cornerInfo-caption_color: white;
$cornerInfo-caption_maxWidth: 410px;
$cornerInfo-caption_fontSize: 12px;

$cornerInfo-caption_marginVertical: 19px;
$cornerInfo-caption_marginHorizontal: 30px;

$cornerInfo-arrow_height: 41px;

.form-control {
  display: block;
  width: 100%;
  height: $input-height-base; // Make inputs at least the height of their button counterpart (base line-height + padding + border)
  font-size: $font-size-base;
  color: $input-color;
  background-color: $input-bg;
  background-image: none; // Reset unusual Firefox-on-Android default style; see https://github.com/necolas/normalize.css/issues/214
  border: 1px solid $input-border;
  border-radius: $input-border-radius; // Note: This has no effect on <select>s in some browsers, due to the limited stylability of <select>s in CSS.
  @include transition(border-color ease-in-out .15s, box-shadow ease-in-out .15s);
}


textarea {
    max-width: 100%;
}

label {
    margin-bottom: 0;
    font-weight: 700;
    color: $input-color-placeholder;
    text-align: center;
    display: block;
    font-size: $font-size-large;
    line-height: $formLabel_lineHeight;
    margin-bottom: $formGroup_paddingTop-_animated - $formLabel_lineHeight;
}

.form-control {
    text-align: center;
    font-size: $font-size-large;
    z-index: 1;
    position: relative;
    border-width: $formControl_borderWidth;

    &,
    &:focus {
        box-shadow: none;
    }
}

.form-group {
    position: relative;

    label,
    .form-control {
        @include transition-duration ($formGroup_transitionDuration);
        @include transition-timing-function ($formGroup_transitionTimingFunction);
    }

    label {
        position: relative;
        @include transition-property (transform, color);
    }

    .form-control {
        @include transition-property (border-width, background-color);
    }

    &.-active,
    &.-focus {
        .form-control {
            border-width: 1px;
            background-color: white;
        }
    }

    &.-animated {
        padding-top: $formGroup_paddingTop-_animated;

        label {
            position: absolute;
            left: 0;
            right: 0;
            top: 0;
            z-index: 0;
            margin-bottom: 0;
            color: $formLabel_color-_animated;
            @include transform (translateY($formGroup_paddingTop-_animated + ($input-height-base / 2) - ($formLabel_lineHeight / 2)));
        }

        &.-active,
        &.-focus {
            label {
                color: $formLabel_color-_animated-_active;
                @include transform (translateY(0));
            }
        }
    }

    &.-overlayed {
        &:before {
            content: "";
            position: fixed;
            background-color: black;
            z-index: -1;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            visibility: hidden;
            opacity: 0;
            @include transition-property (opacity);
            @include transition-duration ($formGroup_transitionDuration);
            @include transition-timing-function ($formGroup_transitionTimingFunction);
        }

        &.-focus {
            &:before {
                z-index: $zindex-modal;
            }

            &:before {
                visibility: visible;
                opacity: 0.5;
            }

            label,
            .form-control {
                z-index: $zindex-modal + 1;
            }

        }
    }
}


// form-caption
// ============

.form-caption {
    position: absolute;
    opacity: 0;
    visibility: hidden;
    background-repeat: no-repeat;
    color: $cornerInfo-caption_color;
    max-width: $cornerInfo-caption_maxWidth;
    font-size: $cornerInfo-caption_fontSize;
  font-style: italic;

    // default position is top-left

    &,
    &.-topLeft,
    &.-leftTop,
    &.-topRight,
    &.-rightTop { // All the top
        top: $formGroup_paddingTop-_animated + $cornerInfo-caption_marginVertical;
        bottom: auto;
        padding-bottom: $cornerInfo-arrow_height;
        padding-top: 0;
        background-position: center bottom;
    }

    &.-bottomRight,
    &.-rightBottom,
    &.-bottomLeft,
    &.-leftBottom { // All the bottom
        bottom: $formGroup_paddingTop-_animated - $cornerInfo-caption_marginVertical;
        top: auto;
        padding-top: $cornerInfo-arrow_height;
        padding-bottom: 0;
        background-position: center top;
    }

    &,
    &.-topLeft,
    &.-leftTop,
    &.-bottomLeft,
    &.-leftBottom { // All the left
        left: $cornerInfo-caption_marginHorizontal * -1;
        right: auto;
    }

    &.-topRight,
    &.-rightTop,
    &.-bottomRight,
    &.-rightBottom { // All the right
        right: $cornerInfo-caption_marginHorizontal * -1;
        left: auto;
    }

    &,
    &.-topLeft,
    &.-leftTop {
        @include transform (translateX(-50%) translateY(-100%));
    }

    &.-topRight,
    &.-rightTop {
        @include transform (translateX(50%) translateY(-100%));
    }

    &.-bottomRight,
    &.-rightBottom {
        @include transform (translateX(50%) translateY(100%));
    }

    &.-bottomLeft,
    &.-leftBottom {
        @include transform (translateX(-50%) translateY(100%));
    }

    &,
    &.-topLeft,
    &.-leftTop,
    &.-topRight,
    &.-rightTop
    &.-bottomRight,
    &.-rightBottom,
    &.-bottomLeft,
    &.-leftBottom {
        @media (max-width: 991px) {
            &,
            &.-touchTop,
            &.-touchBottom {
                left: 50%;
                right: auto;
            }

            &,
            &.-touchTop {
                top: 0 - $cornerInfo-caption_marginVertical;
                bottom: auto;
                padding-bottom: $cornerInfo-arrow_height;
                padding-top: 0;
                @include transform (translateX(-50%) translateY(-100%));
                background-position: center bottom;
            }

            &.-touchBottom {
                bottom: 0 - $cornerInfo-caption_marginVertical;
                top: auto;
                padding-bottom: 0;
                padding-top: $cornerInfo-arrow_height;
                @include transform (translateX(-50%) translateY(100%));
                background-position: center top;
            }
        }
    }
}

.form-group {
    &.-focus {
        .form-caption {
            opacity: 1;
            visibility: visible;
            z-index: $zindex-modal;
        }
    }
}

.panel-footer {
    pre {
        padding: 0;
        border-width: 0;
        margin-bottom: 0;

        + pre {
            margin-top: 20px;
        }
    }
}

.showcase {
    margin-bottom: 60px;

    .form-group {
        margin-bottom: 0;

        + .form-group {
            margin-top: 50px;
        }
    }
}
            
          
!
            
              $('.form-group.-animated .form-control, .form-group.-overlayed .form-control').keyup(function(event) {
    if ($(this).val() != '') {
        $(this).parent('.form-group').addClass('-active');
    } else {
        $(this).parent('.form-group').removeClass('-active');
    }
});

$('.form-group.-animated .form-control, .form-group.-overlayed .form-control').focusin(function(event) {
    $(this).parent('.form-group').addClass('-focus');
});

$('.form-group.-animated .form-control, .form-group.-overlayed .form-control').focusout(function(event) {
    $(this).parent('.form-group').removeClass('-focus');
});
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console