cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

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.

            
              <h1>Basic</h1>
<p>Adds the scrollbar only if the bottom one is present, does not recompute the top scrollbar.</p>

<div class="double-scroll">
  <table>
    <tr>
      <th>AAAAAAAAA</th>
      <th>BBBBBBBBB</th>
      <th>CCCCCCCCC</th>
      <th>DDDDDDDDD</th>
      <th>EEEEEEEEE</th>
      <th>FFFFFFFFF</th>
      <th>GGGGGGGGG</th>
      <th>HHHHHHHHH</th>
    </tr>
    <tr>
      <td>AAAAAAAAA</td>
      <td>BBBBBBBBB</td>
      <td>CCCCCCCCC</td>
      <td>DDDDDDDDD</td>
      <td>EEEEEEEEE</td>
      <td>FFFFFFFFF</td>
      <td>GGGGGGGGG</td>
      <td>HHHHHHHHH</td>
    </tr>
    <tr>
      <td>AAAAAAAAA</td>
      <td>BBBBBBBBB</td>
      <td>CCCCCCCCC</td>
      <td>DDDDDDDDD</td>
      <td>EEEEEEEEE</td>
      <td>FFFFFFFFF</td>
      <td>GGGGGGGGG</td>
      <td>HHHHHHHHH</td>
    </tr>
  </table>
</div>


<h1>Recompute on window resize</h1>
<p>Adds the scrollbar only if the bottom one is present, and recompute the top scrollbar size each time the window is resized.</p>
<p>Resize the window to try!!!!</p>

<div id="sample2">
  <table>
    <tr>
      <th>AAAAAAAAA</th>
      <th>BBBBBBBBB</th>
      <th>CCCCCCCCC</th>
      <th>DDDDDDDDD</th>
      <th>EEEEEEEEE</th>
      <th>FFFFFFFFF</th>
      <th>GGGGGGGGG</th>
      <th>HHHHHHHHH</th>
      <th> IIIIIIIII</th>
      <th>JJJJJJJJJ</th>
    </tr>
    <tr>
      <td>AAAAAAAAA</td>
      <td>BBBBBBBBB</td>
      <td>CCCCCCCCC</td>
      <td>DDDDDDDDD</td>
      <td>EEEEEEEEE</td>
      <td>FFFFFFFFF</td>
      <td>GGGGGGGGG</td>
      <td>HHHHHHHHH</td>
      <td>IIIIIIIII</td>
      <td>JJJJJJJJJ</td>
    </tr>
    <tr>
      <td>AAAAAAAAA</td>
      <td>BBBBBBBBB</td>
      <td>CCCCCCCCC</td>
      <td>DDDDDDDDD</td>
      <td>EEEEEEEEE</td>
      <td>FFFFFFFFF</td>
      <td>GGGGGGGGG</td>
      <td>HHHHHHHHH</td>
      <td>IIIIIIIII</td>
      <td>JJJJJJJJJ</td>
    </tr>
  </table>
</div>


<p>Example for jQuery plugin "jqDoubleScroll": <a href="https://github.com/avianey/jqDoubleScroll">https://github.com/avianey/jqDoubleScroll</a>
</p>
            
          
!
            
              html {
  height: 100%;
}

body {
  padding: 40px;
  background: linear-gradient(130deg, #07d9a3, #048fee);
  background-size: 400% 400%;
  -webkit-animation: gradient 16s ease infinite;
  -moz-animation: gradient 16s ease infinite;
  animation: gradient 16s ease infinite;
}

.double-scroll {
  width: 400px;
}

#sample2 {
  width: 100%;
}


/** Looks better **/

h1 {
  font-family: Calibri;
  color: white;
  font-size: 24px;
  font-style: normal;
  font-variant: normal;
  font-weight: 500;
  line-height: 26.4px;
}

h3 {
  font-family: Calibri;
  color: white;
  font-size: 14px;
  font-style: normal;
  font-variant: normal;
  font-weight: 500;
  line-height: 15.4px;
}

p {
  font-family: Calibri;
  color: white;
  font-size: 14px;
  font-style: normal;
  font-variant: normal;
  font-weight: 400;
  line-height: 20px;
}

a {
  color: #ffffff;
}

table {
  font-family: Calibri;
  color: white;
  border-collapse: collapse;
  border-spacing: 0;
  width: 100%;
  height: 100%;
  margin: 0px;
  padding: 0px;
}

.double-scroll {
  margin-bottom: 40px;
}

tr:nth-child(odd) td {}

tr:nth-child(even) td {
  background-color: rgba(255, 255, 255, 0.2);
}

table td,
table th {
  vertical-align: middle;
  text-align: left;
  padding: 12px;
  font-size: 14px;
  font-family: Calibri;
  color: white;
}

table tr th {
  background-color: transparent !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.6);
  text-align: center;
  font-size: 14px;
  font-family: Calibri;
  font-weight: bold;
}

@-webkit-keyframes gradient {
  0% {
    background-position: 5% 0%
  }
  50% {
    background-position: 96% 100%
  }
  100% {
    background-position: 5% 0%
  }
}

@-moz-keyframes gradient {
  0% {
    background-position: 5% 0%
  }
  50% {
    background-position: 96% 100%
  }
  100% {
    background-position: 5% 0%
  }
}

@keyframes gradient {
  0% {
    background-position: 5% 0%
  }
  50% {
    background-position: 96% 100%
  }
  100% {
    background-position: 5% 0%
  }
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background-color: rgba(255, 255, 255, 0.1);
}

::-webkit-scrollbar-thumb {
  background-color: rgba(255, 255, 255, 0.5);
}

::-webkit-scrollbar-button {
  /*   width: 10px;
  height: 10px;
  background-color: rgba(255, 255, 255, 0.5); */
}
            
          
!
            
              $(document).ready(function() {
  $('.double-scroll').doubleScroll();
  $('#sample2').doubleScroll({
    resetOnWindowResize: true
  });
});

/*
 * @name DoubleScroll
 * @desc displays scroll bar on top and on the bottom of the div
 * @requires jQuery
 *
 * @author Pawel Suwala - http://suwala.eu/
 * @author Antoine Vianey - http://www.astek.fr/
 * @version 0.5 (11-11-2015)
 *
 * Dual licensed under the MIT and GPL licenses:
 * https://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 * 
 * Usage:
 * https://github.com/avianey/jqDoubleScroll
 */
 (function( $ ) {
 	
 	jQuery.fn.doubleScroll = function(userOptions) {
	
		// Default options
		var options = {
			contentElement: undefined, // Widest element, if not specified first child element will be used
			scrollCss: {                
				'overflow-x': 'auto',
				'overflow-y': 'hidden'
			},
			contentCss: {
				'overflow-x': 'auto',
				'overflow-y': 'hidden'
			},
			onlyIfScroll: true, // top scrollbar is not shown if the bottom one is not present
			resetOnWindowResize: false, // recompute the top ScrollBar requirements when the window is resized
			timeToWaitForResize: 30 // wait for the last update event (usefull when browser fire resize event constantly during ressing)
		};
	
		$.extend(true, options, userOptions);
	
		// do not modify
		// internal stuff
		$.extend(options, {
			topScrollBarMarkup: '<div class="doubleScroll-scroll-wrapper" style="height: 20px;"><div class="doubleScroll-scroll" style="height: 20px;"></div></div>',
			topScrollBarWrapperSelector: '.doubleScroll-scroll-wrapper',
			topScrollBarInnerSelector: '.doubleScroll-scroll'
		});

		var _showScrollBar = function($self, options) {

			if (options.onlyIfScroll && $self.get(0).scrollWidth <= $self.width()) {
				// content doesn't scroll
				// remove any existing occurrence...
				$self.prev(options.topScrollBarWrapperSelector).remove();
				return;
			}
		
			// add div that will act as an upper scroll only if not already added to the DOM
			var $topScrollBar = $self.prev(options.topScrollBarWrapperSelector);
			
			if ($topScrollBar.length == 0) {
				
				// creating the scrollbar
				// added before in the DOM
				$topScrollBar = $(options.topScrollBarMarkup);
				$self.before($topScrollBar);

				// apply the css
				$topScrollBar.css(options.scrollCss);
				$self.css(options.contentCss);

				// bind upper scroll to bottom scroll
				$topScrollBar.bind('scroll.doubleScroll', function() {
					$self.scrollLeft($topScrollBar.scrollLeft());
				});

				// bind bottom scroll to upper scroll
				var selfScrollHandler = function() {
					$topScrollBar.scrollLeft($self.scrollLeft());
				};
				$self.bind('scroll.doubleScroll', selfScrollHandler);
			}

			// find the content element (should be the widest one)	
			var $contentElement;		
			
			if (options.contentElement !== undefined && $self.find(options.contentElement).length !== 0) {
				$contentElement = $self.find(options.contentElement);
			} else {
				$contentElement = $self.find('>:first-child');
			}
			
			// set the width of the wrappers
			$(options.topScrollBarInnerSelector, $topScrollBar).width($contentElement.outerWidth());
			$topScrollBar.width($self.width());
			$topScrollBar.scrollLeft($self.scrollLeft());
			
		}
	
		return this.each(function() {
			
			var $self = $(this);
			
			_showScrollBar($self, options);
			
			// bind the resize handler 
			// do it once
			if (options.resetOnWindowResize) {
			
				var id;
				var handler = function(e) {
					_showScrollBar($self, options);
				};
			
				$(window).bind('resize.doubleScroll', function() {
					// adding/removing/replacing the scrollbar might resize the window
					// so the resizing flag will avoid the infinite loop here...
					clearTimeout(id);
					id = setTimeout(handler, options.timeToWaitForResize);
				});

			}

		});

	}

}( jQuery ));

            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console