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

              
                <!-- Toggle layout-overflow class to turn on overflow panels -->
<div class="layout-cell layout-scrollbar">
  <div class="component">Component</div>
  <div class="component">Component</div>
  <div class="component">Component</div>
  <div class="component">Component</div>
  <div class="component">Component</div>
  <div class="component">Component</div>
  <div class="component">Component</div>
  <div class="component">Component</div>
  <div class="component">Component</div>
  <div class="component">Component</div>
  <div class="component">Component</div>
  <div class="component">Component</div>
  <div class="component">Component</div>
</div>
              
            
!

CSS

              
                /* Variables */
:root {
  --scrollbar-size: .375rem;
  --scrollbar-minlength: 1.5rem; /* Minimum length of scrollbar thumb (width of horizontal, height of vertical) */
  --scrollbar-ff-width: thin; /* FF-only accepts auto, thin, none */
  --scrollbar-track-color: transparent;
  --scrollbar-color: rgba(0,0,0,.2);
  --scrollbar-color-hover: rgba(0,0,0,.3);
  --scrollbar-color-active: rgb(0,0,0);
}

/* Use .layout-scrollbar-obtrusive to only use overflow if scrollbars don’t overlay */
.scrollbar-test,
.layout-cell {
  overscroll-behavior: contain;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  -ms-overflow-style: -ms-autohiding-scrollbar;
  scrollbar-width: var(--scrollbar-ff-width);
}

/* This class controls what elements have the new fancy scrollbar CSS */
.layout-scrollbar {
  scrollbar-color: var(--scrollbar-color) var(--scrollbar-track-color);
}
/* Only apply height/width to ::-webkit-scrollbar if is obtrusive */
.layout-scrollbar-obtrusive .layout-scrollbar::-webkit-scrollbar {
  height: var(--scrollbar-size);
  width: var(--scrollbar-size);
}
.layout-scrollbar::-webkit-scrollbar-track {
  background-color: var(--scrollbar-track-color);
}
.layout-scrollbar::-webkit-scrollbar-thumb {
  background-color: var(--scrollbar-color);
  border-radius: 3px;
}
.layout-scrollbar::-webkit-scrollbar-thumb:hover {
  background-color: var(--scrollbar-color-hover);
}
.layout-scrollbar::-webkit-scrollbar-thumb:active {
  background-color: var(--scrollbar-color-active);
}
.scrollbar-test::-webkit-scrollbar-thumb:vertical,
.layout-scrollbar::-webkit-scrollbar-thumb:vertical {
  min-height: var(--scrollbar-minlength);
}
.scrollbar-test::-webkit-scrollbar-thumb:horizontal,
.layout-scrollbar::-webkit-scrollbar-thumb:horizontal {
  min-width: var(--scrollbar-minlength);
}


/* Demo Styles */
html,
body {
  min-height: 100%;
  margin: 0;
}
.layout-cell {
  padding: 1em;
  max-height: 50vh;
  margin: 5vw;
  border: 2px solid rgba(0,0,0,.1);
  background-color: #f9f9f9;
}
.component {
  font-family: sans-serif;
  text-align: center;
  outline: 1px dotted rgba(0,0,0,.2);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 15em;
}
.component:not(:first-child) {
  margin-top: 1em;
}
.component ~ .component:last-child {
  margin-bottom: 1em;
}
              
            
!

JS

              
                /*
 * Scrollbar Width Test
 * Adds `layout-scrollbar-obtrusive` class to body if scrollbars use up screen real estate
 */
var parent = document.createElement("div");
parent.setAttribute("style", "width:30px;height:30px;");
parent.classList.add('scrollbar-test');

var child = document.createElement("div");
child.setAttribute("style", "width:100%;height:40px");
parent.appendChild(child);
document.body.appendChild(parent);

// Measure the child element, if it is not
// 30px wide the scrollbars are obtrusive.
var scrollbarWidth = 30 - parent.firstChild.clientWidth;
if(scrollbarWidth) {
  document.body.classList.add("layout-scrollbar-obtrusive");
}

document.body.removeChild(parent);
              
            
!
999px

Console