Pen Settings

HTML

CSS

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

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

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.

HTML

              
                div.table-wrap
  div.description Element with regulsr scrollbar styled with ::webkit-scrollbar<br>and with scroll handling using scrollLeft JS property
  div.right-wrap.defaultscroll
    for c in [1,2,3,4,5,6,7,8,9]
      div.right-column= c
div.ovhidden(data-scroll-width="50%" data-scroll-left="0")
  div.description Element with custom scrollbar<br>and smooth scroll handling using «transform: translateX» CSS property
  div.right-wrap.customscroll
    for c in [1,2,3,4,5,6,7,8,9]
      div.right-column= c

              
            
!

CSS

              
                * 
  box-sizing: border-box
  margin: 0
  padding: 0

html, body
  width: 100%
  height: 100%
  font-family: Verdana, sans-serif
  

.right-column
  width: 215px
  display: inline-block
  height: 100%
  flex-shrink: 0
  margin: 0 5px
    
.table-wrap, .ovhidden
  width: 100%
  height: 300px
  position: relative
  .right-wrap
    height: 100%
    width: 100%
    display: flex
    flex-direction: row
    overflow-x: auto
    overflow-y: hidden
    transition: all 0.3s ease-in-out
  .right-column
    background: orange
  .description
    color: #fdfdfd
    background: rgba(0,0,0,0.7)
    top: 50%
    transform: translateY(-50%)
    left: 0
    padding: 1em
    position: absolute
    z-index: 100
    
      
.ovhidden
  background: orangered
  padding: 1em 0 1em 0
  overflow-x: hidden
  margin: 1em 0
  width: 100%
  transition: all 0.1s ease-in-out
  .scrollbar-track 
    content: ' '
    display: block
    position: absolute
    white-space: nowrap
    width: 100%
    height: 10px
    background-color: rgba(250,250,250,0.85)
    box-shadow: inset 0 0 2px rgba(0,0,0,0.5)
    border-radius: 10px
    z-index: 100
    bottom: 10px
  .scrollbar-thumb
    content: ' '
    display: block
    position: absolute
    white-space: nowrap
    width: 50%
    left: 0
    height: 10px
    border-radius: 10px
    z-index: 101
    bottom: 10px
    box-shadow: inset 0 0 4px rgba(0,0,0,.3)
    background-color: #999
  .right-wrap
    height: 100%
    width: 100%
    background: gold
    transform: translateX(0px)
    overflow-x: visible
  .right-column
    background: orange

.right-wrap::-webkit-scrollbar
  height: 10px
  background-color: #F5F5F5
  
.right-wrap::-webkit-scrollbar-track
  box-shadow: inset 0 0 4px rgba(0,0,0,0.3)
  border-radius: 10px
  background-color: #F5F5F5

.right-wrap::-webkit-scrollbar-thumb
  border-radius: 10px
  box-shadow: inset 0 0 4px rgba(0,0,0,.3)
  background-color: #999

              
            
!

JS

              
                var ticking = false;

const defaultScroll = function (e) {
  e.preventDefault();
  if (!ticking) {
    let el = this;
    window.requestAnimationFrame(function() {
      el.scrollLeft += e.deltaY;
      console.log(el.scrollLeft, el.scrollWidth, el.parentNode.clientWidth, el.parentNode.offsetWidth);
      ticking = false;
    });

    ticking = true;
  }
}

class customScroll {
  constructor (elembase, elemhidden) {
   this.el = elemhidden; 
   this.container = elembase;
    elembase.appendChild(document.createElement('div')).classList.add('scrollbar-track');
    elembase.appendChild(document.createElement('div')).classList.add('scrollbar-thumb');
    elemhidden.style.width = elemhidden.scrollWidth+'px';
    elembase.addEventListener('wheel', this.scroll.bind(this), {passive: true});
  }
  
  scroll(e) {
    e.preventDefault();
    if (!ticking) {
      window.requestAnimationFrame(function() {
        console.log('scroll',this);
        let curTranslate = 
            +this.el.style.transform.replace(/[^-0-9.]/g, '');
        let setTranslate = curTranslate-e.deltaY;
        let maxPossibleTranslate = this.el.scrollWidth-this.container.clientWidth;
        if (setTranslate > 0) setTranslate = 0;
        else if (setTranslate < -maxPossibleTranslate) 
          setTranslate = -maxPossibleTranslate;
        this.el.style.transform = 
          'translateX('+setTranslate+'px)';
        let newTranslate = this.el.style.transform;
        console.log(newTranslate, this.el.scrollWidth, this.container.clientWidth, this.container.offsetWidth);
        ticking = false;
      });

      ticking = true;

    }
  }
}

window.addEventListener('load', function() {
  const elem = document.querySelector('.defaultscroll');
  const elemhidden = document.querySelector('.customscroll');


  if(elem) elem.addEventListener('wheel', defaultScroll.bind(elem));
  if(elemhidden) 
    custScroll = new customScroll(elemhidden.parentNode, elemhidden); 




});
              
            
!
999px

Console