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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

                <div class="SideScroller">
    <div class="SideScroller__wrap">
      <div class="SideScroller__foreground"></div>
      <div class="SideScroller__mask">
        <div class="SideScroller__line">
          <div class="SideScroller__handle">
            <svg role="img" xmlns="" viewBox="0 0 512 512"><path fill="currentColor" d="M377.941 169.941V216H134.059v-46.059c0-21.382-25.851-32.09-40.971-16.971L7.029 239.029c-9.373 9.373-9.373 24.568 0 33.941l86.059 86.059c15.119 15.119 40.971 4.411 40.971-16.971V296h243.882v46.059c0 21.382 25.851 32.09 40.971 16.971l86.059-86.059c9.373-9.373 9.373-24.568 0-33.941l-86.059-86.059c-15.119-15.12-40.971-4.412-40.971 16.97z"></path></svg>

              $c-handle: #FFFFFF
$c-bg: #afb69e

  height: $n
  width: $n

  border-radius: 50%

  position: absolute
  top: 50%
  left: 50%
  transform: translate(-50%, -50%)

  position: absolute
  top: 0
  left: 0
  bottom: 0
  right: 0

  background: $c-bg
  margin: 0

// - - - -

  padding: 1rem
  max-width: 900px
  margin: 0 auto
  height: 15rem

  @media (min-width: 576px)
    height: 20rem

  @media (min-width: 768px)
    height: 30rem

    height: 100%
    position: relative
    background: url( no-repeat center center
    background-size: cover

    background: url( no-repeat center center
    background-size: cover

    height: 100%
    position: relative

    height: 100%
    width: 2px
    background: $c-handle
    position: absolute
    top: 0
    right: 0
    bottom: 0

    background: $c-handle
    position: absolute
    padding: 10%


              class SideScroller {
  constructor(selector) {
    this.elmClassName = selector.split('.').pop()
    this.wrap = document.getElementsByClassName(`${this.elmClassName}__wrap`)[0]
    this.handle = document.getElementsByClassName(`${this.elmClassName}__handle`)[0]
    this.mask = document.getElementsByClassName(`${this.elmClassName}__mask`)[0]
    this.fg = document.getElementsByClassName(`${this.elmClassName}__foreground`)[0]
    this.pos = 50

  create() {
    this.handle.addEventListener('mousedown', this.drag)
    this.handle.addEventListener('touchstart', this.drag)
    window.addEventListener('resize', this.resizeHandler)

  drag = e => {
    document.addEventListener('mousemove', this.dragHandler)
    document.addEventListener('touchmove', this.dragHandler)
    document.addEventListener('mouseup', this.stopDragHandler)
    document.addEventListener('touchend', this.stopDragHandler)

  resizeHandler = e => {

  dragHandler = e => {
    let percent = this.getPercent(e, this.wrap)
    if (percent < 0) {
      percent = 0
    } else if (percent > 100) {
      percent = 100

  stopDragHandler = e => {
    document.removeEventListener('mousemove', this.dragHandler)
    document.removeEventListener('mouseup', this.stopDragHandler)

  getPercent(evt, elm) {
    let ref = evt.touches
      ? evt.touches[0].pageX
      : evt.pageX
    let rect = elm.getBoundingClientRect()
    return ((ref - rect.left) / rect.width) * 100

  setPosition(percent = this.pos) {
    this.pos = percent = percent + '%'
    const clip = `inset(0 0 0 ${this.wrap.offsetWidth * percent / 100}px)` = clip = clip

new SideScroller('.SideScroller')

🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.