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 id="wrapper">
  <div class="box blue">
    Position static (default
  </div>
  <div class="box red relative">
    Positioned relative - pushed 20px left and 50px from the top - moved to the back (z-index: -1)
  </div>
  <div class="box blue">
    Position static (default)
  </div>
  <div class="box green absolute">
    Positioned absolute - top, left, right, bottom refer to document (not wrapper) <br>Absolutely positioned element is taken out of the document flow
  </div>
  <div class="box yellow fixed">
    Positioned fixed -Element will stay in the viewport when scrolling -similar to `absolute` but fixed to viewport
  </div>
  <div class="box blue">
    Position static (default)
  </div>
  <div class="box purple sticky">
    Positioned sticky - Element placed at normal    position - then keeps 35px from top so it will stay in the viewport when scrolling down - similar to `relative` but stays in viewport once entered
  </div>
  <div class="box blue"></div>
  <div class="box blue"></div>
  <div class="box blue"></div>
  <div class="box blue"></div>
  <div class="box blue"></div>
</div>
              
            
!

CSS

              
                #wrapper {
  max-width: 700px;
  margin: 0 auto;
  border: 2px solid black;
  padding: 1rem;
}

.box {
  width: 350px;
  height: 150px;
}

.red {
  background-color: red;
}

.blue {
  background-color: blue;
}

.green {
  background-color: green;
}

.yellow {
  background-color: yellow;
}

.purple {
  background-color: purple;
}

.relative {
  position: relative;
  left: 20px;
  top: 50px;
  z-index: -1;
}

.absolute {
  position: absolute;
  top: 0px; /* 0px distance to top of document */
  left: 50vw; /* Pushed half the viewport width to the left */
}

.fixed {
  /* Element fixed to the viewport when scrolling */
  position: fixed;
  bottom: 10px;
  right: calc(50vw - 350px - 0.5rem);
}

.sticky {
  position: sticky;
  top: 35px;
  margin-left: -2rem;
}
              
            
!

JS

              
                
              
            
!
999px

Console