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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource


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


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.


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.


This is a series of pens to illustrate the iterations of scroll tracking I've used and the gotchas I've encountered along the way:
<div id="app">
  <navigation :id-blocks="[1,2,3,4,5,6]"></navigation>
  <div class="block" id="1">
    <h1>My Page</h1>
  <div class="block block2" id="2"></div>
  <div class="block" id="3"></div>
  <div class="block" id="4"></div>
  <div class="block block5" id="5"></div>
  <div class="block block6" id="6"></div>


                .block {
  height: 40vh;
  background: cadetblue;
  color: white;

.block2 {
  height: 110vh;
  background: orange;

.block5 {
  height: 40vh;
  background: green;

.block6 {
  height: 40vh;
  background: red;

.block + .block {
  margin-top: 10px;

footer {
  margin-top: 50px;
  background: black;
  height: 200px;

.block:after {
  content: 'Block id: 'attr(id);

body {
  font-family: Avenir, sans-serif;
  font-size: 20px;
  line-height: 28px;

button {
  font-size: inherit;
  line-height: inherit;

// pardon styling elements directly
// trying to keep this simple
nav {
  position: sticky;
  top: 0;
  ol {
    margin: 0;
    display: flex;
    flex-direction: row;
    list-style: none;
  li {
    flex: 1;
    button {
      border: none;
      background: lightgray;
      width: 100%;
      padding: .25em;
      cursor: pointer;
      transition: 300ms;
      &:hover {
        background: white;
      &.isActive {
        color: white;
        background: #666



// The main handler of highlighting appropriate nav items
Vue.component("navigation", {
  name: "navigation",
  props: {
    idBlocks: Array
  data() {
    return {
      activeBlock: null
  mounted() {
    const blockEls = => document.getElementById(el));
    const options = {
      threshold: .5
    const handleIntersectionEvent = (entries) => {
      this.activeBlock = Number(entries[0];
    const observer = new IntersectionObserver(handleIntersectionEvent, options);
    blockEls.forEach(el => observer.observe(el));
  template: `
    <li v-for="block in idBlocks">
        :id="'link' + block"
        :class="{isActive: block === activeBlock}"
      >Block {{block}}</button>

new Vue({
  el: "#app",
  data() {
    return {
      test: "string"