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


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.


                <script src=""></script>
<!-- normally scripts should be added to "Settings" for the codepen,
     but for clarity, adding it here -->

<div class="custom-slider"  touch-action="pan-y">
  <div class="custom-slider-track">
    <div class="custom-slider-button">


                .custom-slider { touch-action: pan-y; } 

html { background: #eee; }

.custom-slider { width: 100%; height: 7em; padding: 1em; box-sizing: border-box; }
.custom-slider-track { width: 100%; height: 100%; background: #2d89ef; box-sizing: border-box; position:relative; }
.custom-slider-button { width: 5em; height: 5em; background: #2b5797; box-sizing: border-box; position:absolute; top:0; left:0; } { background:  #ff0097; }

.custom-slider-button {	user-select: none; -moz-user-select: none; -khtml-user-select: none; -webkit-user-select: none; }


                /* exactly the same code as before - only difference is we added PEP
   to make our much cleaner pointer events example work for mouse and touch
   even in non-pointer-events browsers - clean, future-proof code polyfilled
   for old and current browsers; compare this to the mouse+touch monstrosity... */

var t = document.querySelector(".custom-slider-button");

t.addEventListener('pointerdown', sliderdown, true);
t.addEventListener('pointermove', slidermove, true);
t.addEventListener('pointerup', sliderup, true);

function sliderdown(e) {
	var t =;

function sliderup(e) {
  var t =;

function slidermove(e) {
  var t =;

  if ((t.hasPointerCapture && t.hasPointerCapture(e.pointerId)) || t.classList.contains('active')) {
  	var newpos = e.clientX - t.parentElement.offsetLeft - (t.offsetWidth/2);
	  if (newpos < 0) {
		  newpos = 0;
	  } else if ( newpos > (t.parentElement.offsetWidth - t.offsetWidth)) {
		  newpos = t.parentElement.offsetWidth - t.offsetWidth;
	  } = newpos +'px';