123

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.

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.

            
              <h1>Laying out a form using grid</h1>
<h2>1. Stacked layout</h2>
<form class="grid-stacked">
  <div class="input-group">
    <label for="name">Name:</label>
    <input type="text" name="name" id="name" placeholder="Your name ...">
  </div>
  <div class="input-group">
    <label for="email">Email:</label>
    <input type="email" name="email" id="email" placeholder="Your email ...">
  </div>
  <div class="input-group">
    <label for="message">Message:</label>
    <textarea name="message" id="message" rows="10" placeholder="Your message here ..."></textarea>
  </div>
  <input type="submit" value="Submit">
</form>
<h2>2. Inline layout</h2>
<form class="grid-inline">
  <div class="input-group">
    <label for="name">Name:</label>
    <input type="text" name="name" id="name" placeholder="Your name ...">
  </div>
  <div class="input-group">
    <label for="email">Email:</label>
    <input type="email" name="email" id="email" placeholder="Your email ...">
  </div>
  <div class="input-group">
    <label for="message">Message:</label>
    <textarea name="message" id="message" rows="10" placeholder="Your message here ..."></textarea>
  </div>
  <input type="submit" value="Submit">
</form>
<h1>Laying out a form using flexbox</h1>
<h2>1. Stacked layout</h2>
<form class="flex-stacked">
  <div class="input-group">
    <label for="name">Name:</label>
    <input type="text" name="name" id="name" placeholder="Your name ...">
  </div>
  <div class="input-group">
    <label for="email">Email:</label>
    <input type="email" name="email" id="email" placeholder="Your email ...">
  </div>
  <div class="input-group">
    <label for="message">Message:</label>
    <textarea name="message" id="message" rows="10" placeholder="Your message here ..."></textarea>
  </div>
  <div class="input-group">
    <input type="submit" value="Submit">
  </div>
</form>
<h2>2. Inline layout</h2>
<form class="flex-inline">
  <div class="input-group">
    <label for="name">Name:</label>
    <input type="text" name="name" id="name" placeholder="Your name ...">
  </div>
  <div class="input-group">
    <label for="email">Email:</label>
    <input type="email" name="email" id="email" placeholder="Your email ...">
  </div>
  <div class="input-group">
    <label for="message">Message:</label>
    <textarea name="message" id="message" rows="10" placeholder="Your message here ..."></textarea>
  </div>
  <div class="input-group">
    <input type="submit" value="Submit">
  </div>
</form>
            
          
!
            
              @import url('https://fonts.googleapis.com/css?family=Open+Sans');

/* sttacked grid form styling */
.grid-stacked {
  display: grid;
}
.grid-stacked .input-group{
  display: grid;
}

/* inline grid form styling */
.grid-inline {
  display: grid;
  grid-template-rows: 1fr;
}
.grid-inline .input-group {
  display: grid;
  grid-template-columns: 30% 70%;
}
/* stacked flex form styling */
.flex-stacked, flex-inline {
  display: flex;
  flex-direction: column;
}
.flex-stacked .input-group {
  display: flex;
  flex-direction: column;
}

/* inline flex form styling */
.flex-inline .input-group {
  display: flex;
}
.flex-inline .input-group label{
  flex-basis: 30%;
}
.flex-inline .input-group input {
  flex-basis: 70%;
}
.flex-inline .input-group textarea {
  flex-basis: 70%;
}

/* general styling */
body {
  font-family: 'Open Sans', sans-serif;
}

form {
  width: 400px;
  padding: 20px;
  color: #fff;
  background-color: #50677b;
  box-shadow: 4px 6px 9px 0px rgba(0,0,0,0.75);
}
.input-group {
  margin-bottom: 10px;
}
input[type="text"], input[type="email"]{
  height: 2em;
}
input[type="submit"]{
  display: block;
  margin-left: auto;
  width: 100px;
  max-width: 100px;
  height: 30px;
  color: #fff;
  background-color: #8494a2;
  outline: none;
  border: none;
}
input[type="submit"]:hover {
  background-color: #202931;
}

/* let's make the form mobile friendly */
@media (max-width: 576px) {
  form{
    width: 300px;
  }
}
            
          
!
            
              // just some code to prevent form submission
$('form').on('submit', function(e){
  e.preventDefault();
});
            
          
!
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.

Console