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="container">
  <div>
    <h1>Avoid jumpy numbers with font-feature-settings: 'tnum'</h1>
    <span class="regular">0</span><br>
    <span class="tabular">0</span>
    <div>
      <button>Animate</button>
    </div>
  </div>
</div>
            
          
!
            
              
@font-face {
  font-family: 'Montserrat';
  src: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/176026/montserrat-v11-latin-400.woff2');
}

html {
  color: rgb(62,57,107);
  background-image: linear-gradient(to bottom left, rgb(248,250,255) 0%, rgb(238, 240, 247) 100%);
  text-shadow: 0px 1px 2px rgba(62,57,107,0.2);
  font-family: 'Montserrat', sans-serif;
  text-rendering: optimizelegibility;
}

h1 {
  line-height: 1.7;
  font-size: 28px;
  font-weight: bold;
  margin-bottom: 48px
}

.container {
  display: flex;
  width: 100vw;
  height: 100vh;
  align-items: center;
  justify-content: space-around;
  text-align: center;
}

span { 
  font-weight: bold;
  font-size: 48px;
  margin: 40px;
}

button {
  margin-top: 48px;
  background-color: transparent;
  color: rgb(62,57,107);
  border-radius: 4px;
  border: 2px solid rgb(62,57,107);
  padding: 12px 24px;
  font-size: 20px;
  &:active {
    transform: scale(.95)
  }
}

/* ^^ */
.regular {
  font-feature-settings: "pnum";
}
.tabular {
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
}


            
          
!
            
              

const easeOutQuart = (t, b, c, d) => {
  return -c * (( t = t / d - 1) * t * t * t - 1) + b;
};

const spans = [...document.querySelectorAll('span')];

const animate = value => {
    const time = {
    total: 4000,
    start: performance.now()
  };
  const tick = now => {
    const elapsed = now - time.start,
          progress = easeOutQuart(elapsed, 0, 1, time.total);

    spans.forEach(s => s.textContent = Math.round(progress * value).toLocaleString())
    elapsed < time.total ? window.requestAnimationFrame(tick) : null;
  }
  window.requestAnimationFrame(tick);
}
  
window.addEventListener('load', () => {
  animate(50000)
})

document.querySelector('button').addEventListener('click', () => {
  animate(Math.round(Math.random()*50000))
});
    
    
            
          
!
999px
Loading ..................

Console