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.

            
              #progressarea
  #filler
  .textarea
    h2.title Progress fill
    #percent ...
    p.description a simple design pattern

            
          
!
            
              @import url('https://fonts.googleapis.com/css?family=Inconsolata');
$corner-radius: 3px;
$size: 300px;
%middlebox {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
body {
  background-color: darkblue;
}
#progressarea {
  @extend %middlebox;
  cursor: pointer;
  width: $size;
  height: $size * 1.5;
  background-color: skyblue;
  box-shadow: .125rem .125rem .5rem 0 rgba(0, 0, 0, .5);
  border: {
    radius: $corner-radius;
    width: 1px;
    color: midnightblue;
    style: solid;
  }
  font-family: 'Inconsolata', monospace;
  text-align: center;
  .textarea {
    @extend %middlebox;
    color: green;
    mix-blend-mode: luminosity;
    * {
      margin: 0;
      &:first-child {
        margin-bottom: 1.5rem;
      }
      &:last-child {
        margin-top: 1.5rem;
      }
    }
  }
  .title {
    font-size: 2.2rem;
  }
  .description {
    font-size: 1rem;
  }
}
#percent {
  font: {
    weight: bold;
    size: 2rem;
  }
}
#filler {
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 0;
  border-radius: $corner-radius;
  background-color: blue;
  opacity: .5;
  transition: height .4s;
}

            
          
!
            
              // simulate some progress
(function app() {

  const delayedSteps = [
    {p: 0, d: 1000},
    {p: 1, d: 100},
    {p: 2, d: 100},
    {p: 3, d: 100},
    {p: 4, d: 400},
    {p: 10, d: 1000},
    {p: 14, d: 500},
    {p: 17, d: 1000},
    {p: 22, d: 2000},
    {p: 29, d: 1500},
    {p: 30, d: 100},
    {p: 31, d: 100},
    {p: 32, d: 200},
    {p: 33, d: 100},
    {p: 34, d: 100},
    {p: 35, d: 50},
    {p: 36, d: 100},
    {p: 40, d: 600},
    {p: 46, d: 2500},
    {p: 50, d: 1000},
    {p: 51, d: 100},
    {p: 52, d: 100},
    {p: 53, d: 100},
    {p: 54, d: 100},
    {p: 55, d: 100},
    {p: 68, d: 1000},
    {p: 69, d: 100},
    {p: 70, d: 100},
    {p: 71, d: 200},
    {p: 72, d: 100},
    {p: 83, d: 800},
    {p: 92, d: 2000},
    {p: 98, d: 800},
    {p: 99, d: 200},
    {p: 100, d: 500}
  ];
  
  let isProgress = false;
  
  const event = {
    init() {
      document.addEventListener('DOMContentLoaded', this.onDomReady);
      view.area.addEventListener('click', this.onClickRestart);
    },
    onDomReady() {
      controller.simulateProgress(delayedSteps);
    },
    onClickRestart() {
      controller.simulateProgress(delayedSteps);
    }
  };

  const view = {
    init() {
      this.area = document.getElementById('progressarea');
      this.percent = document.getElementById('percent');
      this.filler = document.getElementById('filler');
    },
    drawFill(percent = 0) {
      this.filler.style.height = `${percent}%`;
    },
    writePercent(percent = 0) {
      this.percent.textContent = `${percent}%`;
    },
    setPercent(percent = 0) {
      this.drawFill(percent);
      this.writePercent(percent);
    },
    setProgressCursor(progress = false) {
      this.area.style.cursor = `${(progress) ? 'progress' : 'pointer'}`;
    }
  };

  const controller = {
    simulateProgress(delayedSteps) {
      if (isProgress) return;
      isProgress = true;
      view.setProgressCursor(isProgress);
      const stepNum = delayedSteps.length;
      let step = 0;
      let currentStep = null;
      (function gotoStep() {
        currentStep = delayedSteps[step];
        view.setPercent(currentStep.p);
        step += 1;
        if (step < stepNum) {
          setTimeout (gotoStep, currentStep.d);
        } else {
          isProgress = false;
          view.setProgressCursor(isProgress);
        }
      }());
    }
  };

  (function init() {
    view.init();
    event.init();
  }());
}());

            
          
!
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