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 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

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

              
                <header class="m-header">
  <div class="wrapper">
    <h1>
      HTML Form with Numeric Keyboard and Autofill Support
    </h1>

    <nav>
      <ul>
        <li>
          <a href="#" class="is-active">
            Example
          </a>
        </li>
        <li>
          <a href="#">
            Example
          </a>
        </li>
        <li>
          <a href="">
            Example
          </a>
        </li>
        <li>
          <a href="#">
            Example
          </a>
        </li>
      </ul>  
    </nav>
  </div>
</header>

<div class="wrapper">
  <form action="" method="POST" class="m-form js-form">
    <div>
      <input type="hidden" name="hidden" value="foobar">
    </div>

    <div class="grid">
      <div class="col col50">
        <div class="m-form__item">
          <label for="name" class="m-form__label">Name:</label>
          <input type="text" name="name" id="name" class="field" autocomplete="name">
        </div>
      </div>

      <div class="col col50">
        <div class="m-form__item">
          <label for="email" class="m-form__label">E-Mail:</label>
          <input type="email" name="email" id="email" placeholder="my@server.net" class="field" autocomplete="email">
        </div>
      </div>
    </div>

    <div class="grid">
      <div class="col col50">
        <div class="m-form__item">
          <label for="phone" class="m-form__label">Phone:</label>
          <input type="tel" name="phone" id="phone" class="field" autocomplete="tel">
        </div>
      </div>

      <div class="col col50">
        <div class="m-form__item">
          <label for="options" class="m-form__label">Select field</label>
          <select name="options" id="options" class="field" autocomplete="off">
            <option value="" selected disabled>Please choose</option>
            <option value="1">Option 1</option>
            <option value="2">option 2</option>
            <option value="3">option 3</option>
          </select>
        </div>
      </div>
    </div>
    
    <div class="grid">
      <div class="col col25">
        <div class="m-form__item">
          <label for="zip" class="m-form__label">PLZ:</label>
          <input type="number" name="telefon" id="zip" class="field" pattern="[0-9]*" inputmode="numeric" data-numeric-input autocomplete="shipping postal-code">
        </div>
      </div>
      
      <div class="col col75">
        <div class="m-form__item">
          <label for="city" class="m-form__label">Ort:</label>
          <input type="tel" name="city" id="city" class="field" autocomplete="shipping locality">
        </div>
      </div>
    </div>

    <p>
      <label for="hallo">Über dich:</label>
      <textarea name="hallo" id="hallo" class="field"></textarea>
    </p>

    <p>
      <label class="textlabel">
        <input type="checkbox" name="agb" value="ja" checked>
        AGB akzeptieren
      </label>
    </p>

    <p>
      <span class="label">Ihr Geschlecht:</span>

      <label class="textlabel">
        <input type="radio" name="geschlecht" value="frau" checked>
        Frau
      </label>

      <label class="textlabel">
        <input type="radio" name="geschlecht" value="mann">
        Mann
      </label>
    </p>

    <p>
      <button type="submit" class="button">Absenden</button>
    </p>
  </form>
</div>
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css?family=Bree+Serif|Roboto');

$layout-spacing: 24px;
$border-radius: 3px;
$color--text: #263238;

html {
  box-sizing: border-box;
}

*,
*::after,
*::before {
  box-sizing: inherit;
}

body {
  background: #CFD8DC;
  color: $color--text;
  font-family: 'Roboto', sans-serif;
}

.wrapper {
  padding: 0 24px;
  max-width: 650px;
  margin: 0 auto;
}

@for $i from 1 to 6 {
  h#{$i} {
    font-family: 'Bree Serif', serif;
  }
}

.m-header {
  background: #0D47A1;
  color: #ECEFF1;
  padding: 24px 0;
  margin: 0 0 48px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
    
  h1 {
    margin: 0;
  }
  
  ul {
    padding: 0;
    list-style: none;
    overflow: hidden;
    margin: 24px -24px 0;
    border-top: 1px solid #E3F2FD;
  }
  
  li {
    float: left;
    width: 50%;
  }
  
  a {
    display: block;
    color: #E3F2FD;
    padding: 8px 24px;
    text-decoration: none;
    border-bottom: 1px solid #E3F2FD;
    transition: all 70ms ease-in-out;
    
    &:hover {
      background: transparentize(#E3F2FD, .8);
    }
  }
  
  @media (min-width: 500px) {
    padding-bottom: 0;
    border-bottom: 5px solid darken(#0D47A1, 10%);
    
    ul {
      border: 0;
      margin: 24px 0 -5px;
    }
    
    li {
      width: 25%;
    }
    
    a {
      border: 0;
      border-bottom: 5px solid transparent;
      padding: 18px 24px 18px 12px;
      
      &.is-active,
      &:hover {
        background: none;
        border-bottom-color: #E3F2FD;
      }
    }
  }
}


// ┌──────────────────────────────────┐
//   GRID
// └──────────────────────────────────┘

.grid {
  overflow: hidden;
  
  .col {
    margin-bottom: $layout-spacing;
    
    p:last-child {
      margin-bottom: 0;
    }
  }
    
  @media (min-width: 500px) {
    margin-left: (-$layout-spacing);

    .col {
      float: left;
      padding-left: $layout-spacing;
      margin-bottom: 0;

      &.col25 {
        width: 25%;
      }

      &.col50 {
        width: 50%;
      }
      
      &.col75 {
        width: 75%;
      }
    }
  }
}

.m-form {
  &__item {
    margin: 0 0 $layout-spacing;
    
    [type="text"],
    [type="tel"],
    [type="email"],
    [type="number"],
    select {
      display: block;
      width: 100%;
      border: 1px solid #78909C;
      color: $color--text;
      padding: .5em;
      outline: none;
      border-radius: $border-radius;
      font-size: inherit;

      &:focus {
        background: #FFF9C4;
        box-shadow: 0 0 10px rgba(38, 50, 56, .5);
      }
    }
    
    select {
      height: 36px;
    }
    
    textarea {
      display: block;
    }
    
    // disable arrow keys in number fields
    [data-numeric-input] {
      -moz-appearance: textfield;

      &::-webkit-inner-spin-button,
      &::-webkit-outer-spin-button {
        -webkit-appearance: none;
        margin: 0;
      }
    }
  }
  
  &__label {
    display: inline-block;
    font-size: .8em;
    color: #546E7A;
    margin: 0 0 .2em 0;
  }

  .textlabel {
    display: inline-block;
    font-size: 1em;
    margin: 0;
    color: #263238;
    padding-right: 1em;

    input {
      display: inline;
      width: auto;
    }
  }


  .button {
    border: 1px solid #78909C;
    border-radius: $border-radius;
    background: #78909C;
    color: #ECEFF1;
    padding: 8px 24px;
    transition: background 200ms ease-in-out;

    &:hover {
      background: darken(#78909C, 10%);
    }
  }
}

              
            
!

JS

              
                var navLinks = document.querySelectorAll('.m-header nav a');

var ignoreLink = function(event) {
  event.preventDefault();
};

for(var i = 0; i < navLinks.length; i++) {
  navLinks[i].addEventListener('click', ignoreLink);
}













































$('.js-form').on('submit', function(e) {
  e.preventDefault();
  
  var form = $(this);
  var data = form.serializeArray();
  
  console.log(data);
});
              
            
!
999px

Console