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.


                <h1>SVG slider clickable</h1>

<div class="slider">
  <svg width="302" height="49" viewBox="0 0 302 49" xmlns="">
   <g fill="none" fill-rule="evenodd">
      <path d="M0 0h302v49H0V0z" fill-opacity=".659" fill="#5A1999"/>
      <path d="M13 13h275v7H13v-7z" fill="#231A5D"/>
      <path d="M14 14h273v5H14v-5z" fill="#CBA9FF"/>

      <path class="green-bar" d="M14 14h128v5H14v-5z" fill="#997519"/>
      <circle fill="#E3D73C" cx="39" cy="15.5" r="7.5"/>

      <path d="M15 23h2v7h-2v-7zm26 0h2v7h-2v-7zm27 0h2v7h-2v-7zm27 0h2v7h-2v-7zm26 0h2v7h-2v-7zm25 0h2v7h-2v-7zm27 0h2v7h-2v-7zm27 0h2v7h-2v-7zm27 0h2v7h-2v-7zm27 0h2v7h-2v-7zm31 0h2v7h-2v-7z" fill="#FFF"/>

      <text fill="#DDD" font-family="Verdana" font-size="9.051">
         <tspan x="13" y="40" fill="#000">0</tspan>
      <text fill="#DDD" font-family="Verdana" font-size="9.051">
         <tspan x="39" y="40" fill="#000">1</tspan>
      <text fill="#DDD" font-family="Verdana" font-size="9.051">
         <tspan x="66" y="40" fill="#000">2</tspan>
      <text fill="#DDD" font-family="Verdana" font-size="9.051">
         <tspan x="93" y="40" fill="#000">3</tspan>
      <text fill="#DDD" font-family="Verdana" font-size="9.051">
         <tspan x="119" y="40" fill="#000">4</tspan>
      <text fill="#F6D81E" font-family="Verdana" font-size="9.051">
         <tspan x="144" y="40" fill="#000">5</tspan>
      <text fill="#DDD" font-family="Verdana" font-size="9.051">
         <tspan x="171" y="40" fill="#000">6</tspan>
      <text fill="#DDD" font-family="Verdana" font-size="9.051">
         <tspan x="198" y="40" fill="#000">7</tspan>
      <text fill="#DDD" font-family="Verdana" font-size="9.051">
         <tspan x="225" y="40" fill="#000">8</tspan>
      <text fill="#DDD" font-family="Verdana" font-size="9.051">
         <tspan x="252" y="40" fill="#000">9</tspan>
      <text fill="#DDD" font-family="Verdana" font-size="9.051">
         <tspan x="280" y="40" fill="#000">10</tspan>


                        svg {
          cursor: pointer;
        circle {
          transform: translateX(30px);
        circle:hover {
          fill: #e4e4e4;
        tspan {
          -webkit-touch-callout: none;
          -webkit-user-select: none;
          -khtml-user-select: none;
          -moz-user-select: none;
          -ms-user-select: none;
          user-select: none;
        text:after {
            position: absolute;
            top: 0;
            width: 10px;
            height: 10px;
            background: orange;
            z-index: 10;
        text:hover {
          fill: #fff;
        .bounce {
          animation: bounce 200ms ease-out;

        @-webkit-keyframes bounce {
            from, to  {
              transform: translate3d(197%, 0, 0);
              animation-timing-function: ease-out;
            50% {
              transform: translate3d(230%, 0, 0);
              animation-timing-function: ease-in;


                        $(function() {

          function slider(e) {
            if(e.which==1) {
              var offset = $(this).offset();
              var curPos = (e.pageX - offset.left - 30);
              var obj = $("text");
              var arr = [];
              var elements = document.getElementsByTagName("text");
              for (x = 0; x < elements.length; x++) {

                var nearestNum = elements[x].children[0].attributes.x.value;

                // loop to array

                function findClosest(array,elem) {
                  var minDelta = null;
                  var minIndex = null;
                  for (var i = 0 ; i<array.length; i++){
                    var delta = Math.abs(array[i]-elem);
                    if (minDelta == null || delta < minDelta){
                      minDelta = delta;
                      minIndex = i;
                    // if it is a tie return an array of both values
                    else if (delta == minDelta) {
                      return [array[minIndex],array[i]];
                    // if it has already found the closest value
                    else {
                      return array[i-1];
                  return array[minIndex];
                var closest = findClosest(arr,curPos);

              if ( e.pageX  < 50 ) {
                curPosBar = 0;
              } else {
                var curPosBar = Number(closest) + 12;

              $(".green-bar").attr("d","M14 14h"+ curPosBar +"v5H14z");

            //  reset all text back to white. 
              $(" tspan ").closest("text").attr("fill","#DDD");

              if (curPos < 12) {
                // if minus amount. 
                $("circle").attr("cx", "-13");
                $(" tspan[x=13] ").closest("text").attr("fill", "#F6D81E");  
              } else {
                $("circle").attr("cx", +closest);
                $(" tspan[x=" + closest + "] ").closest("text").next().attr("fill", "#F6D81E");


                // remove class after CSS animation complete.
              }, 500);


          $("svg").on("mousemove", slider);

          $("svg").on("mousedown", slider);