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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

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

Visit your global Editor Settings.

HTML

              
                <div class="section">
  <h2>CSS-Only Animated &lt;label&gt; Reminder</h2>
  <p>CSS-Only Animated 'Reminder' Placeholders using &lt;label&gt; by <a href="https://codepen.io/sivan/">Sivan</a></p>

  <form class="form-label form-css-label">
    <fieldset>
      <input id="firstName" name="firstName" type="text" autocomplete="off" required />
      <label for="firstName">First Name</label>
    </fieldset>
    <fieldset>
      <input id="lastName" name="lastName" type="text" autocomplete="off" required />
      <label for="lastName">Last Name</label>
    </fieldset>
    <fieldset>
      <input id="email" name="email" type="text" autocomplete="off" required />
      <label for="email">Email Address</label>
    </fieldset>
  </form>

  <form class="form-label form-css-label">
    <fieldset>
      <input id="username" name="username" type="text" autocomplete="off" required />
      <label for="username">Username</label>
    </fieldset>
    <fieldset>
      <input id="password" name="password" type="password" autocomplete="off" required />
      <label for="password">Password</label>
    </fieldset>
    <fieldset>
      <input id="cpassword" name="cpassword" type="password" autocomplete="off" required />
      <label for="cpassword">Confirm Password</label>
    </fieldset>
  </form>
  
  <p>JS-version Animated 'Reminder' Placeholders using &lt;label&gt; supported HTML5 input type</p>
  <form class="form-label form-js-label">
    <fieldset>
      <input id="userName" name="userName" type="text" autocomplete="off" required />
      <label for="userName">User Name</label>
    </fieldset>
    <fieldset>
      <input id="userEmail" name="userEmail" type="email" autocomplete="off" required />
      <label for="userEmail">Email Address</label>
    </fieldset>
    <fieldset>
      <input id="description" name="description" type="text" autocomplete="off" />
      <label for="description">Desciption (not required)</label>
    </fieldset>
  </form>
</div>

              
            
!

CSS

              
                /**
 * Sivan[sun.sivan@gmail.com]
 * This pen is using Autoprefixer
 */

// Main
fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

input {
  display: block;
  width: 100%;
  height: 3em;
  padding: 16px 8px;
  border: 0;
  border-radius: 0;
  font-size: 16px;
  font-weight: 400;
  line-height: 1;
  background: rgba(255,255,255,0.97);
  color: #212121;
  outline: 0;
  appearance: none;
  transition: all 0.2s ease-in-out;
}

.form-label {
  fieldset {
    position: relative;
    &:first-child input {
      border-radius: 4px 4px 0 0;
    }
    &:last-child input {
      border-radius: 0 0 4px 4px;
      box-shadow: 0 2px 0 rgba(0,0,0,0.15);
    }
    & + fieldset { border-top: 1px solid #ddd; }
  }
  label {
    position: absolute;
    top: 15px;
    left: 8px;
    color: #909090;
    transform: translate3d(0, 0, 0);
    transition: all 0.2s ease-in-out;
  }
}

// Animation on <label>
.form-css-label {
  input {
    &[data-empty="false"],
    &:valid,
    &:focus {
      padding: 22px 8px 10px;
    }
    &:focus {
      outline: 0;
      background: rgba(255,255,255,1);
    }
    &[data-empty="false"] + label,
    &:valid + label,
    &:focus + label {
      color: #5856D6;
      font-weight: 700;
      font-size: 12px;
      transform: translate3d(0, -10px, 0);
    }
  }
}

.form-js-label {
  input {
    &[data-empty="false"],
    &:focus {
      padding: 22px 8px 10px;
    }
    &:focus {
      outline: 0;
      background: rgba(255,255,255,1);
    }
    &[data-empty="false"] + label,
    &:focus + label {
      color: #5856D6;
      font-weight: 700;
      font-size: 12px;
      transform: translate3d(0, -10px, 0);
    }
  }
}

// Common Style
*,
*:before,
*:after {
  box-sizing: border-box;
}

html, body { height: 100%; }

body {
  font: 16px/1 "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-weight: 200;
  background: url("http://f.ggssh.com/label-bg.jpg") 50% 50%;
  background-size: cover;
  color: #212121;
}

a {
  color: #adff2f;
  text-decoration: none;
  &:hover {
    text-decoration: underline;
  }
}

.section {
  width: 80%;
  min-width: 320px;
  margin: 100px auto;
  text-align: center;
  text-shadow: -1px -1px rgba(0, 0, 0, 0.1);
  color: #fff;
  h2 {
    margin: 0 0 .5em;
    font-size: 24px;
    font-weight: 400;
    line-height: 1.25;
  }
  p {
    margin: 0 0 1em;
  }
  form {
    max-width: 320px;
    margin: 0 auto 20px;
  }
}

              
            
!

JS

              
                $('.form-js-label').find('input').on('input', function (e) {
  $(e.currentTarget).attr('data-empty', !e.currentTarget.value);
});
              
            
!
999px

Console