Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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="input-wrapper">
  <!-- 
  Input needs to have a placeholder in order to use :placeholder-shown pseudo class in Safari.
  We then hide it using CSS.
  -->
  <input autocomplete="off" class="input" type="text" id="name" placeholder="Name" />
  <label class="label" for="name">
    Name
  </label>
  <button class="clear" aria-label="Clear input">
    <svg viewBox="0 0 16 16" width="12" height="12">
      <path d="M 1 1 L 15 15 M 1 15 L 15 1" fill="none" stroke-width="2" stroke="currentColor" />
    </svg>
  </button>
</div>

<div class="input-wrapper">
  <input autocomplete="off" class="input" type="email" id="email" placeholder="Email" />
  <label class="label" for="email">
    Email
  </label>
  <button class="clear" aria-label="Clear input">
    <svg viewBox="0 0 16 16" width="12" height="12">
      <path d="M 1 1 L 15 15 M 1 15 L 15 1" fill="none" stroke-width="2" stroke="currentColor" />
    </svg>
  </button>
</div>
              
            
!

CSS

              
                * {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}

body {
  padding: 20px;
  font-size: 20px;
  background: #f3f4f6;
}

@media (min-width: 600px) {
  body {
    padding: 40px;
  }
}

.input-wrapper {
  position: relative;
  margin-top: 30px; // To create space for floating inputs
  margin-inline: auto;
  max-width: 400px;
}

.input {
  font-size: 20px;
  width: 100%;
  padding: 8px 0;
  padding-right: 30px; // To avoid overlapping with the clear button
  color: #333;
  border: none;
  border-bottom: 1px solid #ddd;
  transition: border-color 250ms;
  background-color: transparent;

  &:focus {
    outline: none;
    border-bottom-color: #777;
  }

  &::placeholder {
    color: transparent;
  }
  
  // Hide Safari's autofill button
  &::-webkit-contacts-auto-fill-button {
    visibility: hidden;
    pointer-events: none;
    position: absolute;
  }
}

.label {
  position: absolute;
  top: 8px;
  left: 0;
  color: #43454e;
  pointer-events: none;
  transform-origin: left center;
  transition: transform 250ms;
  font-family: "Iowan Old Style", "Palatino Linotype", "URW Palladio L", P052,
    serif;
}

.input:focus + .label,
.input:not(:placeholder-shown) + .label {
  transform: translateY(-100%) scale(0.75);
}

.clear {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  position: absolute;
  top: 50%;
  right: -9px; // To visually align with inputs right edge
  transform: translateY(-50%);
  background: none;
  border: none;
  border-radius: 50%;
  height: 30px;
  width: 30px;
  color: #777;
  transition: color 250ms;
  display: flex;
  align-items: center;
  justify-content: center;

  &:hover,
  &:focus {
    color: #333;
  }
}

.input:placeholder-shown + .label + .clear {
  display: none;
}

              
            
!

JS

              
                [...document.querySelectorAll('.clear')].forEach($clearButton => {
  const $searchInput = $clearButton.parentElement.querySelector('.input');

  $clearButton.addEventListener('click', () => {
    $searchInput.value = '';
    $searchInput.focus();
  });
});
              
            
!
999px

Console