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 class="custom-rangeslider">
  <input class="custom-rangeInput round-corner" title="Percentage" id="range-slider1" type="range" min="0" max="100" value="50" step="1" data-tooltip="true" aria-controls="rangeTooltip rangeLabel" aria-live="polite">
  <span class="custom-rangeslider__tooltip">0</span>
  <span class="custom-rangeslider__label">
    <span class="custom-rangeslider__label-min">0</span>
    <span class="custom-rangeslider__label-max">100</span>
  </span>
</div>


              
            
!

CSS

              
                body {
	 margin: 50px 50px;
	 font-family: noto, sans-serif;
	 font-size: 12px;
	 font-weight: none;
}

 .custom-rangeslider {
	 position: relative;
	 margin-top: 40px;
	 padding: 0;
   
   
}
 .custom-rangeInput {
	 width: 100%;
	 background: transparent;
	 appearance: none;
	 box-sizing: border-box;
	 cursor: pointer;
	 outline: 0;
	 border: 0;
	 padding: 0;
	 margin: 0;
	 background-color: transparent;
	 height: 20px;
}
 .custom-rangeInput::-webkit-slider-thumb {
	 appearance: none;
	 box-sizing: border-box;
	 background-color: #ffffff;
	 border: 2px solid #A6BBC8;
	 width: 20px;
	 height: 20px;
	 border-radius: 50px;
	 cursor: move;
	 cursor: grab;
	 cursor: -moz-grab;
	 cursor: -webkit-grab;
	 margin-top: -8px;
}
 .custom-rangeInput::-webkit-slider-thumb:active {
	 cursor: grabbing;
	 cursor: -moz-grabbing;
	 cursor: -webkit-grabbing;
}
 .custom-rangeInput::-moz-range-thumb {
	 appearance: none;
	 box-sizing: border-box;
	 background-color: #ffffff;
	 border: 2px solid #A6BBC8;
	 width: 20px;
	 height: 20px;
	 border-radius: 50px;
	 cursor: move;
	 cursor: grab;
	 cursor: -moz-grab;
	 cursor: -webkit-grab;
}
 .custom-rangeInput::-moz-range-thumb:active {
	 cursor: grabbing;
	 cursor: -moz-grabbing;
	 cursor: -webkit-grabbing;
}
 .custom-rangeInput::-ms-thumb {
	 appearance: none;
	 box-sizing: border-box;
	 background-color: #ffffff;
	 border: 2px solid #A6BBC8;
	 width: 20px;
	 height: 20px;
	 border-radius: 50px;
	 cursor: move;
	 cursor: grab;
	 cursor: -moz-grab;
	 cursor: -webkit-grab;
	 margin: auto;
}
 .custom-rangeInput::-ms-thumb:active {
	 cursor: grabbing;
	 cursor: -moz-grabbing;
	 cursor: -webkit-grabbing;
}
 .custom-rangeInput::-webkit-slider-runnable-track {
	 appearance: none;
	 box-sizing: border-box;
	 height: 4px;
	 width: 100%;
	 cursor: pointer;
	 border: none;
	 padding: 0;
	 margin: 0;
	 background: #f4f4f4;
}
 .custom-rangeInput::-moz-range-track {
	 appearance: none;
	 box-sizing: border-box;
	 height: 4px;
	 width: 100%;
	 cursor: pointer;
	 border: none;
	 padding: 0;
	 margin: 0;
	 background: #f4f4f4;
}
 .custom-rangeInput::-ms-track {
	 appearance: none;
	 box-sizing: border-box;
	 height: 4px;
	 width: 100%;
	 cursor: pointer;
	 border: none;
	 padding: 0;
	 margin: 0;
	 background: #f4f4f4;
	 color: transparent;
	 border: none;
	 outline: none;
}
 .custom-rangeInput:focus, .custom-rangeInput:active {
	 outline: none;
}
 .custom-rangeInput::-ms-tooltip {
	 display: none;
}
 .custom-rangeslider__tooltip {
	 line-height: 20px;
	 position: absolute;
	 height: 20px;
	 width: 40px;
	 background-color: #131E29;
	 padding: 4px 4px;
	 border: 1px #131E29 solid;
	 top: -40px;
	 left: 0;
   color: #ffffff;
	 text-align: center;
	 transform: translate(-26%, 0);
	 border-radius: 4px;
	 -webkit-touch-callout: none;
	 -webkit-user-select: none;
	 -khtml-user-select: none;
	 -moz-user-select: none;
	 -ms-user-select: none;
	 -o-user-select: none;
	 user-select: none;
	 pointer-events: none;
}
 .custom-rangeslider__tooltip:after {
	 display: block;
	 content: ' ';
	 background: #131E29;
	 position: absolute;
	 border-top: 0;
	 border-left: 0;
	 width: 8px;
	 height: 8px;
	 left: calc(50% - 4px);
	 bottom: -5px;
	 transform: rotate(45deg);
}
 .custom-rangeslider__label {
	 width: 100%;
	 display: block;
}
 .custom-rangeslider__label span {
	 display: block;
}
 .custom-rangeslider__label-min {
	 float: left;
}
 .custom-rangeslider__label-max {
	 float: right;
}
 .custom-rangeslider__label:after {
	 content: "";
	 display: table;
	 clear: both;
}
 

              
            
!

JS

              
                (function(win, dom){
    'use strict';
  
    // Check for .rangeControl class
    var rangeControlList = dom.getElementsByClassName('custom-rangeInput');
  
    // Inits components
    var init = function(){
      
      // Loop all controls
      for (var i = 0; i < rangeControlList.length; i++) {
        
        // Apply inital
        updateController(rangeControlList[i]);
        // Update when changed
        rangeControlList[i].addEventListener('input', function() {
          updateController(this);
        });
        // Update when changed ( for older browsers )
        rangeControlList[i].addEventListener('change', function() {
          updateController(this);
        });
      }
    }
    
    // Updates components
    var update = function(){
      for (var i = 0; i < rangeControlList.length; i++) {
         updateController(rangeControlList[i]);
      }
    }

    // Update controller
    var updateController = function(obj){
      // Thumb Position
      var thumbPos = getThumbPercentage(obj);
      var thumPosPX = getThumbPosition(obj);
      if(obj.getAttribute("data-tooltip") != "false"){
        updateTooltip(obj.nextElementSibling, obj.value, thumPosPX, thumbPos);
      }else{
        obj.nextElementSibling.style.display = "none";
      }
      updateProgress(obj, '#DBE2E9', '#0074cc', thumbPos);
    }

    // Retun range slider pixel position according to offset
    // obj : target object
    var getThumbPosition = function(obj){
      return Math.round((obj.offsetWidth / 100) * obj.value); // Pixel
    }

    // Retun range slider percentage to thumb position
    // obj : target object
    var getThumbPercentage = function(obj){
      return Math.round(100 * obj.value/obj.getAttribute("max")); // Percentage
    }
    
    // Updated range slider tooltip
    // obj : target object
    // text : tooltip label
    // position : absolute position
    // percentage : percentage of current value
    var updateTooltip = function(obj, text, position, percentage){
      obj.innerHTML = text; // Tooltip text
      obj.style.left = position + 'px'; // Tooltip position

      // Tooltip Position
      var tooltipStartPos = 26;
      var tooltipPosFix = percentage / 1.8;
      if(percentage > 50){
        tooltipPosFix = percentage / 2.2;
      }
      obj.style.transform = 'translate(-'+ (tooltipStartPos + tooltipPosFix) +'%, 0)';
    }
    
    // Updated background progress bar of range slider
    // obj : target object
    // progressBgColor : background color
    // progressFillColor : fill color
    // percentage : percentage of current value
    var updateProgress = function(obj, progressBgColor, progressFillColor, percentage){
      var rangeBg = 'linear-gradient(to right,  '+ progressFillColor +' 0%, '+ progressFillColor +' '+ percentage +'%, '+ progressBgColor +' '+ percentage +'%, '+ progressBgColor +' 100%)';
      var cssRule = '#'+ obj.id +'::-webkit-slider-runnable-track { background : '+ rangeBg +' } ';
      cssRule += '#'+ obj.id +'::-moz-range-track { background : '+ rangeBg +' } ';
      cssRule += '#'+ obj.id +'::-ms-track { background : '+ rangeBg +' } ';
      var applyStyle = function(styleName, cssText) {
          var styleElement = dom.getElementById(styleName);
          if (styleElement) dom.getElementsByTagName('head')[0].removeChild(styleElement);
          
          styleElement = dom.createElement('style');
          styleElement.type = 'text/css';
          styleElement.id = styleName;
          styleElement.innerHTML = cssText;
          dom.getElementsByTagName('head')[0].appendChild(styleElement);
      }
      applyStyle('range_'+ obj.id, cssRule);
    }
    
  // Refresh on resize
  var fireOnceOnResize;
  win.addEventListener('resize', function () {
    fireOnceOnResize = setTimeout(update, 100);
  });
  
  // Init Component
  init();
  
}(window, document));
              
            
!
999px

Console