Pen Settings

HTML

CSS

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

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

Behavior

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.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

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.

HTML

              
                <h1><a href="https://material.io/design/components/text-fields.html">Material Design</a> like form input text fields with CSS only</h1>

<div class="container">
  <form novalidate>
    <div class="row">
      <div class="col-sm">
        <div class="form-field">
          <div class="form-field__control">
            <input id="firstname" type="text" class="form-field__input" placeholder=" " />
            <label for="firstname" class="form-field__label">First name</label>
            <div class="form-field__bar"></div>
          </div>
        </div>
      </div>
      <div class="col-sm">
        <div class="form-field">
          <div class="form-field__control">
            <input id="lastname" type="text" class="form-field__input" placeholder=" " />
            <label for="lastname"class="form-field__label">Last name</label>
            <div class="form-field__bar"></div>
          </div>
        </div>
      </div>
    </div>
    <div class="row">
      <div class="col-sm">
        <div class="form-field">
          <div class="form-field__control">
            <input id="email" type="email" class="form-field__input" placeholder=" " />
            <label for="email" class="form-field__label">Email</label>
            <div class="form-field__bar"></div>
          </div>
        </div>
      </div>
    </div>
    <div class="row">
      <div class="col-sm">
        <div class="form-field">
          <div class="form-field__control">
            <input id="street" type="text" class="form-field__input" placeholder=" " />
            <label for="street"class="form-field__label">Street address</label>
            <div class="form-field__bar"></div>
          </div>
        </div>
      </div>
    </div>
    <div class="row">
      <div class="col-sm">
        <div class="form-field">
          <div class="form-field__control">
            <input id="zip" type="text" class="form-field__input" placeholder=" " />
            <label for="zip"class="form-field__label">Zip code</label>
            <div class="form-field__bar"></div>
          </div>
        </div>
      </div>
      <div class="col-sm">
        <div class="form-field">
          <div class="form-field__control">
            <input id="city" type="text" class="form-field__input" placeholder=" " />
            <label for="city"class="form-field__label">City</label>
            <div class="form-field__bar"></div>
          </div>
        </div>
      </div>
    </div>
    <div class="row">
      <div class="col-sm">
        <div class="form-field">
          <div class="form-field__control">
            <textarea id="additionalInfo" class="form-field__textarea" placeholder=" "></textarea>
            <label for="additionalInfo" class="form-field__label">Additional info</label>
            <div class="form-field__bar"></div>
          </div>
        </div>      
      </div>
    </div>
  </form>
</div>

<p style="text-align:center">Read more: <a href="https://auralinna.blog/post/2018/how-to-create-material-design-like-form-text-fields" target="_blank" rel="noopener noreferrer">How to create Material Design like form text fields with floating label and animated underline bar</a></p>

<p style="text-align:center">See also: <a href="https://codepen.io/teroauralinna/pen/rZZGpe" target="_blank">Javascript version</a></p>
              
            
!

CSS

              
                html, body {
  color: #333;
  font-size: 16px;
  line-height: 20px;
}
body {
  margin: 20px;
}

h1 {
  line-height: 1.2;
  margin-bottom: 35px;
  text-align: center;
}

.container {
  margin: 0 auto 35px;
  max-width: 450px;
}

/* Actual code example */

$primary-color: #b11adc;
$animation-duration: 0.4s;

@mixin label-inactive() {
  font-size: 1.2rem;
  transform: translateY(0);
}

@mixin label-active() {
  font-size: 0.75rem;
  transform: translateY(-14px);
}

.form-field {
  display: block;
  margin-bottom: 16px;
}
.form-field__label {
  @include label-active();
  display: block;
  font-weight: normal;
  left: 0;
  margin: 0;
  padding: 18px 12px 0;
  position: absolute;
  top: 0;
  transition: all $animation-duration;
  width: 100%;
}
.form-field__control {
  background: #eee;
  border-radius: 8px 8px 0 0;
  overflow: hidden;
  position: relative;
  width: 100%;
}
.form-field__bar {
  border-bottom: 2px solid $primary-color;
  bottom: 0;
  content: "";
  display: block;
  left: 0;
  margin: 0 auto;
  position: absolute;
  right: 0;
  transform: scaleX(0);
  transition: all $animation-duration;
  width: 1%;
}
.form-field__input,
.form-field__textarea {
  appearance: none;
  background: transparent;
  border: 0;
  border-bottom: 1px solid #999;
  color: #333;
  display: block;
  font-size: 1.2rem;
  margin-top: 24px;
  outline: 0;
  padding: 0 12px 10px 12px;
  width: 100%;
  
  // IE 10-11
  &:-ms-input-placeholder {
    ~ .form-field__label {
      @include label-inactive();
    }
  }
  // All other browsers except Edge
  &:placeholder-shown {
    ~ .form-field__label {
      @include label-inactive();
    }
  }
  &:focus {
    ~ .form-field__label {
      color: $primary-color;
      @include label-active();
    }
    ~ .form-field__bar {
      border-bottom: 2px solid $primary-color;
      transform: scaleX(150);
    }
  }
}
.form-field__textarea {
  height: 150px;
}

              
            
!

JS

              
                
              
            
!
999px

Console