cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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.

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

<div class="container">
  <form>
    <div class="form-field">
      <div class="form-field__control">
        <label for="firstname" class="form-field__label">First name</label>
        <input id="firstname" class="form-field__input" />
      </div>
    </div>
    <div class="form-field">
      <div class="form-field__control">
        <label for="lastname" class="form-field__label">Last name</label>
        <input id="lastname" class="form-field__input" />
      </div>
    </div>
    <div class="form-field">
      <div class="form-field__control">
        <label for="additionalInfo" class="form-field__label">Additional info</label>
        <textarea id="additionalInfo" class="form-field__textarea"></textarea>
      </div>
    </div>
  </form>
</div>

            
          
!
            
              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: 400px;
}

/* Actual code example */

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

.form-field {
  display: block;
  margin-bottom: 16px;
  
  &--is-active {
    .form-field__control {
      &:after {
        border-bottom: 2px solid $primary-color;
        transform: scaleX(150);
      }
    }
    .form-field__label {
      color: #b11adc;
      font-size: 0.75rem;
      transform: translateY(-14px);
    }
  }
}
.form-field__label {
  top: 0;
  display: block;
  font-size: 1.2rem;
  font-weight: normal;
  left: 0;
  margin: 0;
  padding: 18px 12px 0 ;
  position: absolute;
  transition: all $animation-duration;
  width: 100%;
}
.form-field__control {
  background: #eee;
  border-radius: 8px 8px 0 0;
  overflow: hidden;
  position: relative;
  width: 100%;
  
  &:after {
    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%;
}
.form-field__textarea {
  height: 150px;
}

            
          
!
            
              const setActive = (el, active) => {
  if (active) {
    el.parentNode.parentNode.className = 'form-field form-field--is-active'
  } else {
    if (el.value === '') {
      el.parentNode.parentNode.className = 'form-field'
    }
  }
}

Array.prototype.forEach.call(
  document.querySelectorAll('.form-field__input, .form-field__textarea'),
  (el) => {
    el.onblur = () => {
      setActive(el, false)
    }
    el.onfocus = () => {
      setActive(el, true)
    }
  }
)

            
          
!
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.
Loading ..................

Console