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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                <h1>Scalable <b>3D</b> Range Sliders</h1>

<main class="perspective" id="first-bar">
  <section class="bar">
    <div class="bar-face back percentage"></div>
    <div class="bar-face floor percentage"></div>
    <div class="bar-face roof percentage"></div>
    <div class="bar-face front percentage"></div>
  </section>
  <input class="bar-input" type="range" min="0" max="101" value="64" />
</main>
<p>Simple Range</p>


<main class="perspective" id="second-bar">
<section class="bar">
    <div class="bar-face back percentage"></div>
    <div class="bar-face floor percentage"></div>
    <div class="bar-face roof percentage"></div>
    <div class="bar-face front percentage"></div>
  </section>
<input class="bar-input" type="range" min="0" max="101" value="37" />
</main>
<p>Patterned Range</p>


<main class="perspective" id="third-bar">
<section class="bar">
    <div class="bar-face back percentage"></div>
    <div class="bar-face floor percentage"></div>
    <div class="bar-face roof percentage"></div>
    <div class="bar-face front percentage"></div>
     <div class="indicator">89%</div>
  </section>
<input class="bar-input" type="range" min="0" max="100" value="89" />
</main>
<p class="third-bar-p">Gradient Range with Indicator</p>
              
            
!

CSS

              
                /*
Thanks to the following for help:
https://tympanus.net/codrops/2015/09/30/shaded-progress-bars-css-sass-excercise/
*/
@import url('https://fonts.googleapis.com/css?family=Nunito:400,900');

$highlight: #4D5075;

$height1: 7vh;
$length1: 55vh;
$bg-bar1: rgba(white, 0.5);
$fill-bar1:rgba(#954169, 0.6);

$height2: 10vh;
$length2: 40vh;
$bg-bar2: rgba(#3C4B84, 0.5);
$fill-bar21: #867292;
$fill-bar2: #C8D4FA;

$height3: 8vh;
$length3: 42vh;
$bg-bar3: rgba(#E89AAD, 0.7);
$fill-bar31: rgba(#F5EFC8, 0.5);
$fill-bar3: #ec0071;

* {
  box-sizing: border-box;
}

body,
html {
  font-family: "Nunito", sans-serif;
  background: linear-gradient(0deg, #EEEFED, #F9E3E9);
  margin: 0;
  padding: 0;
  color: $highlight;
  font-weight: 300;
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 7vh 15vw 0vh 15vw;
}

h1 {
  text-align: center;
  margin: 0 0 10vh 0;
  font-size: 7vh;
  font-weight: 500;
  text-shadow: 0px -15px 70px rgba($highlight, 0.6);
}

h1 b {
  font-weight: 900;
}

p {
  text-align: center;
  font-size: 1.3rem;
  text-shadow: 10px 5px 25px rgba($highlight, 0.6);
  margin-bottom: 8vh;
}

.third-bar-p {
  margin-top: 7vh;
}

.perspective {
  perspective: 70vh;
  text-align: center;
  perspective-origin: 50% 50%;
  position: relative;
  transition: transform 0.3s ease;
  &:hover {
    transform: scale(1.04);
  }
}

.bar-input {
  position: absolute;
  height: 100%;
  left: 0;
  right: 0;
  margin: auto;
  opacity: 0;
}

#first-bar .bar-input {
  width: $length1;
}

#second-bar .bar-input {
  width: $length2;
}

#third-bar .bar-input {
  width: $length3;
}

.bar {
  display: inline-block;
  position: relative;
  transform: rotateX(55deg);
  transform-style: preserve-3d;
  .bar-face {
    display: inline-block;
    width: 100%;
    height: 100%;
    position: absolute;
    left: 0;
    transform-origin: 50% 100%;

    &.front {
      transform: rotateX(-90deg);
    }

    &.percentage:before {
      height: 100%;
      content: "";
      display: block;
      position: absolute;
      bottom: 0;
      margin: 0;
    }
  }
}

@mixin build-skin($color) {
  &.floor {
    box-shadow: 0 1.3em 1.2em -0.4em rgba(0,0, 70, 0.25),
      0 -2em 15em 0.5em rgba($highlight, 1), 0 -0.75em 25em 10em rgba(white, 0.4);
  }

  &.percentage:before {
    box-shadow: 0 1.6em 7em -0.3em rgba($color, 0.5);
  }
}

#first-bar .bar {
  width: $length1;
  height: $height1;
  .bar-face {
    background: $bg-bar1;
    @include build-skin($fill-bar1);

    &.roof {
      transform: translateZ($height1);
    }

    &.back {
      transform: rotateX(-90deg) translateZ(-$height1);
    }

    &.percentage:before {
      background-color: $fill-bar1;
    }
  }
}

#second-bar .bar {
  width: $length2;
  height: $height2;
  .bar-face {
    @include build-skin($fill-bar2);
    background: $bg-bar2;
    background-image: linear-gradient(90deg, rgba($fill-bar21, 0.5), rgba($bg-bar2, 0.1)),url('https://zephyo.github.io/22Days/code/5/graphics/stars.svg'),
      url('https://zephyo.github.io/22Days/code/5/graphics/stars2.svg');
    background-repeat: repeat repeat;
    &.roof {
      transform: translateZ($height2);
    }

    &.back {
      transform: rotateX(-90deg) translateZ(-$height2);
    }

    &.percentage:before {
       background-image: url('https://zephyo.github.io/22Days/code/5/graphics/sky.png');
       opacity: 0.9;
    }
  }
}

$indicator-size: 8vh;

#third-bar .bar {
  width: $length3;
  height: $height3;
  .bar-face {
    @include build-skin($fill-bar3);
    background: $bg-bar3;

    &.roof {
      transform: translateZ($height3);
    }

    &.back {
      transform: rotateX(-90deg) translateZ(-$height3);
    }

    &.percentage:before {
      background: linear-gradient(90deg, $fill-bar31,$fill-bar3);
    }
  }

  .indicator {
    box-shadow: 0px 15px 35px rgba($fill-bar3, 0.3);
    background: $fill-bar3;
    width: $indicator-size;
    height: $indicator-size;
    color: white;
    transform: translateY($height3 * 1.2);
    text-align: center;
    font-size: 2.5vh;
    font-weight: 900;
    line-height: $indicator-size;
    &:before {
      content: "";
      position: absolute;
      background: $fill-bar3;
      left: 0;
      right: 0;
      margin: auto;
      top: -6px;
      width: $indicator-size/2;
      height: $indicator-size/2;
      z-index: -1;
      transform: rotate(45deg);
    }
  }
}

              
            
!

JS

              
                function initInputs() {
  var allInputs = document.body.querySelectorAll(".bar-input");

  for (var i = 0; i < allInputs.length; i++) {
    var input = allInputs[i];
    var barId = input.parentNode.id;
    var styleEl = document.head.appendChild(document.createElement("style"));

    if (i == allInputs.length - 1) {
      //set indicator
      var indicator=input.parentNode.querySelector('.bar .indicator');
      setBarIndicator(barId, input, styleEl, indicator);
      input.oninput = setBarIndicator.bind(this, barId, input, styleEl, indicator);
      input.onchange = setBarIndicator.bind(this, barId, input, styleEl, indicator);
    } else {
      setBar(barId, input, styleEl);
      input.oninput = setBar.bind(this, barId, input, styleEl);
      input.onchange = setBar.bind(this, barId, input, styleEl);
    }
  }
}

function setBar(barId, input, styleEl) {
  styleEl.innerHTML =
    "#" + barId + " .bar-face.percentage:before {width:" + input.value + "%;}";
}

function setBarIndicator(barId, input, styleEl, indicatorEl) {
  styleEl.innerHTML =
    "#" + barId + " .bar-face.percentage:before {width:" + input.value + "%;}";
  indicatorEl.style.marginLeft = (input.value - 10) + '%';
  indicatorEl.textContent = input.value + '%';
}

initInputs();

              
            
!
999px

Console