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 id="container">
  <div id="menu">
    <div>
      <a href="#" class="has-submenu">Open submenu</a>

      <div class="submenu">
        <div>
          <a href="https://example.com">example.com</a>
        </div>
        <div>
          <a href="https://example.com">example.com</a>
        </div>
        <div>
          <a href="https://example.com">example.com</a>
        </div>
        <div>
          <a href="https://example.com">example.com</a>
        </div>
        <div>
          <a href="https://example.com">example.com</a>
        </div>
        <div>
          <a href="https://example.com">example.com</a>
        </div>
      </div>
    </div>
  </div>
</div>

<div id="how-to">
  <h1>Draggable onClick issues on Chrome 55</h1>
  <ol>
    <li>Use Chrome 55</li>
    <li>Set Sensors/Touch to "Force Enabled" or use Chrome 55 on a touch screen (doesn't matter)</li>
    <li>Tap "Open submenu"</li>
    <li>The onClick callback is used to hide the "Open submenu" link (using display: none), which is then replaced by a link to example.com (using display: block).</li>
    <li><strong>Bug:</strong> the user is redirected to example.com despite the e.preventDefault() in the onClick callback.
  </ol>
</div>
</div>
              
            
!

CSS

              
                #wrapper {
  display: flex;
}

#container {
  background: #ddd;
  width: 200px;
  text-align: center;
  height: 170px;
  overflow: hidden;
}

#menu {
  padding-bottom: 500px; // draggable padding
}

a {
  display: block;
  padding: 10px 5px;
  border: 1px solid #ccc;
}

.submenu {
  display: none;
}

#how-to {
 padding-left: 30px; 
}

a:active {
  background: red;
  color: #000;
}
              
            
!

JS

              
                let draggable = Draggable.create( document.querySelector( '#container' ), {
  type: "scrollTop",
  edgeResistance: 0.7,
  throwProps: true,
  dragClickables: true,
  allowNativeTouchScrolling: false,
  onClick: function( e ) {
    e.preventDefault();
    e.stopPropagation();

    console.log( e );
    
    if ( e.target.classList.contains( 'has-submenu' ) ) {
      e.target.style.display = 'none';
      e.target.parentNode.querySelector( '.submenu' ).style.display = 'block';
    }
  }
		
} );
              
            
!
999px

Console