cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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.

Quick-add: + add another resource

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.

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.

            
              <div class="page">
  <div class="page__demo">
    <div class="page__container">
      <input type="radio" id="pink" name="colors" class="switch" checked>
      <input type="radio" id="purpure" name="colors" class="switch">
      <input type="radio" id="green" name="colors" class="switch">
      <div class="demo">
        <div class="js-progressbar">
          <span class="js-progressbar__value"></span>
          <progress class="progress js-progressbar__progress" max="100"></progress>
        </div>        
        <div class="control-panel">
          <div class="control-panel__item">
            <span class="control-panel__hint">Select color:</span>
            <label for="pink" class="select-color select-color_pink">Pink</label>
            <label for="purpure" class="select-color select-color_purpure">Purpure</label>
            <label for="green" class="select-color select-color_green">Green</label>
          </div>
          <div class="control-panel__item">
            <span class="control-panel__hint">Select value:</span>
            <input class="range js-range" type="range" min="0" max="100" step="5" value="70">
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
            
          
!
            
              /*
=====
LEVEL 1. CORE STYLE FOR COMPONENTS. IT DOESN'T INCLUDE PRESENTATION STYLES AND MODIFIERS
=====
*/

.progress{
	display: block;
	appearance: none;
	border: none;
}

/*
=====
LEVEL 2. CORE STYLE FOR COMPONENTS MODIFIERS. IT DOESN'T INCLUDE PRESENTATION STYLES
=====
*/

.progress{
	--uiProgressWidth: var(--progressWidth, 100%);
	--uiProgressHeight: var(--progressHeight, 5px);
	width: var(--uiProgressWidth);
	height: var(--uiProgressHeight);
}

.progress[value]::-webkit-progress-value{
	transition: width .4s ease-out;
}

/*
=====
LEVEL 3. COMPONENTS PRESENTATION STYLE
=====
*/

.progress{
	--uiProgressColor: var(--progressColor);
	--uiProgressBgColor: var(--progressBgColor);
	background-color: var(--uiProgressColor);
	color: var(--uiProgressColor);
}

.progress[value]::-webkit-progress-bar{
	background-color: var(--uiProgressBgColor);
}

.progress[value]::-webkit-progress-value{
	background-color: var(--uiProgressColor);
}

.progress[value]::-moz-progress-bar{
	background-color: var(--uiProgressColor);
}

/*
=====
LEVEL 4. SETTINGS COMPONENTS
=====
*/

.progress{
  --progressHeight: 4px;
}

#pink:checked ~ .demo .progress{
  --progressColor: #C21858;
  --progressBgColor: #F8BBD0;
}

#purpure:checked ~ .demo .progress{
  --progressColor: #512DA8;
  --progressBgColor: #D1C4E9;  
}

#green:checked ~ .demo .progress{
  --progressColor: #388E3C;
  --progressBgColor: #C8E6C9;    
}

/*
* demo page
*/

@media (min-width: 768px){

  html{
    font-size: 62.5%;
  }
}

@media (max-width: 767px){

  html{
    font-size: 50%;
  }
}

body{
  font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Open Sans, Ubuntu, Fira Sans, Helvetica Neue, sans-serif;
  font-size: 1.6rem;
  color: #222;

  margin: 0;
  -webkit-overflow-scrolling: touch;   
  overflow-y: scroll;
}

.page{
  min-height: 100vh;
  display: flex;
}

.page__demo{
  display: flex;
  flex-grow: 1;
}

.page__container{
  width: 100%;
  max-width: 768px;
  padding-left: 2rem;
  padding-right: 2rem;
  margin: auto;  
}

/* control-panel */

.control-panel{
  margin-top: 5rem;
  margin-bottom: 5rem;
}

.control-panel__item{
  display: flex;
  align-items: center;
  margin-right: 5%;
}

.control-panel__hint{
  font-weight: 700;
  margin-right: 1rem;
}

@media (max-width: 640px){
  
  .control-panel__item:nth-child(n+2){
    margin-top: 40px;
  }
}

@media (min-width: 640px){
  
  .control-panel{
    display: flex;
    justify-content: center;
  }
}

/* select select-color */

.select-color{
  display: inline-block;
  width: 3.5rem;
  height: 3.5rem;
  
  margin-left: 1rem;
  margin-right: 1rem;

  cursor: pointer;
  overflow: hidden;
  border-radius: 50%;
  text-indent: -999px;
}

.select-color_pink{
  background-color: #C2185B;
}

.select-color_purpure{
  background-color: #512DA8;
}

.select-color_green{
  background-color: #388E3C;
}

/* switch */

.switch{
  position: absolute;
  top: 0;
  left: -9999px;
}

/* range */

.range{
  appearance: none;
}

.range::-webkit-slider-runnable-track{
  height: 3px;
  cursor: pointer;
  background-color: #F8BBD0;
  border: none;
}

.range::-webkit-slider-thumb{
  width: 2rem;
  height: 2rem;
  appearance: none;  
  
  transform: translateY(-50%);
  background-color: #C21858;
  border-radius: 50%;
}

.range::-moz-range-track{
  height: 3px;
  cursor: pointer;
  background-color: #F8BBD0;
  border: none;
}

.range::-moz-range-thumb{
  width: 2rem;
  height: 2rem;
  appearance: none;
  border: none;
  
  transform: translateY(-5%);
  background-color: #C21858;
  border-radius: 50%;
}

/* js-progress */

.js-progressbar__value{

  display: block;
  text-align: center;
  margin-bottom: 3rem;
  
  font-size: 5rem;  
  font-weight: 700;
}

            
          
!
            
              
(function(){
  'use strict';

  class Progress{
    constructor(node){
      this.nodeProgress = node;
    }

    setValue(newValue){
      this.nodeProgress.value = newValue;
    }
  }

  class Range{
    constructor(node){
      this.nodeRange = node;
    }
    
    getValue(){
      return this.nodeRange.value;
    }
  }    
  
  class ProgressBar extends Progress {
    constructor(node){
      super();
      this.nodeProgressBar = node;
      this.nodeProgress = this.nodeProgressBar.querySelector('.js-progressbar__progress');
      this.nodeProgressBarValue = this.nodeProgressBar.querySelector('.js-progressbar__value');
    }
    
    setValue(newValue){
      super.setValue(newValue);
      this.nodeProgressBarValue.textContent = `${newValue}%`;
    }
  }
 
  let demoProgressBar = new ProgressBar(document.querySelector('.js-progressbar'));
  let demoRange = new Range(document.querySelector('.js-range'));

  function setValueForDemoProgress(){
    demoProgressBar.setValue(demoRange.getValue());
  } 
  
  setValueForDemoProgress();
  demoRange.nodeRange.addEventListener("change", setValueForDemoProgress);
})();


            
          
!
999px
Loading ..................

Console