123

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <!--
  The purpose of this demo is to show how a 
  "days remaining" CTA link could be built.

  The countdown is simulated, and sped WAY up
  since the idea here would be that the day notificaion
  would change once every 24 hours.

  Note there may be visual rendering issues with IE11,
  and count down announcements may need further revisions
  with pre-Chromium Edge.
-->
<div class="sr-only" role="status" id="session_countdown"></div>
<a href="#" class="preview-link" aria-label="7 Days left to sign up now">
  <svg aria-hidden="true" focusable="false" viewBox="0 0 100 100" class="preview-link__timer">
    <circle cx="50" cy="50" r="45"/>
    <circle cx="50" cy="50" r="45" id="countdown_segment"/>
    <text x="34" y="-30" fill="#fff" id="countdown_number">7</text>
  </svg>
  <span class="preview-link__small" role="presentation">Days Left to</span>
  <span class="preview-link__cta" role="presentation">Sign Up Now</span>
</a>
<!--
  when navigating with virual cursor, NVDA would 
  treat each element within the link as a separate
  virtual cursor stop when using up/down arrows.

  Updating the aria-label on the wrapping <a> element
  will ensure that NVDA correctly announces the link
  as a single string / virtual cursor focus stop.
-->
            
          
!
            
              *,
*:before,
*:after {
  box-sizing: border-box;
}
body {
  background: #1a1a1a;
  font-family: arial;
  text-align: center;
  padding-top: 2em;
  font-size: 1.4em;
}

.sr-only {
  position: absolute;
  height: 1px;
  width: 1px;
  white-space: nowrap;
  overflow: hidden;
  opacity: 0;
}

.preview-link {
  color: #ffdd40;
  display: inline-block;
  position: relative;
  padding-left: 1.75em;
  text-decoration: none;
}

.preview-link:hover,
.preview-link:focus {
  outline: 2px solid;
  outline-offset: 4px;
}

.preview-link__small {
  color: #fff;
  display: block;
  font-size: .625em;
  text-align: left;
  line-height: 1.2;
}

.preview-link__cta {
  display: block;
  font-size: .75em;
}

.preview-link__timer {
  bottom: 0;
  height: 1.45em;
  margin: auto;
  overflow: visible;
  position: absolute;
  left: 0;
  top: 0;
  transform: rotate(-90deg);
  width: 1.45em;
}

.preview-link__timer circle {
  fill: transparent;
  stroke-width: 14px;
  stroke: #fff;
  transition: stroke-dasharray .2s ease-in-out, stroke .2s ease-in;
}

.preview-link__timer text {
  fill: #fff;
  transform: rotate(90deg);
  font-size: 2.75em;

}

#countdown_segment {
  stroke: #4c8bf2;
  transition: stroke-dasharray .2s ease-in-out;
  stroke-dasharray: 0, 360;
}

#countdown_segment.ellapsed-1 {
  stroke-dasharray: 20.5, 360;
}
#countdown_segment.ellapsed-2 {
  stroke-dasharray: 61, 360;
}
#countdown_segment.ellapsed-3 {
  stroke-dasharray: 101.5, 360;
}
#countdown_segment.ellapsed-4 {
  stroke-dasharray: 142, 360;
}
#countdown_segment.ellapsed-5 {
  stroke-dasharray: 182.5, 360;
}
#countdown_segment.ellapsed-6 {
  stroke-dasharray: 223, 360;
}
#countdown_segment.ellapsed-7 {
  stroke: #f00;
  stroke-dasharray: 308, 360;
}
            
          
!
            
              (function ( doc, w, undfined ) {
  var announcer = doc.getElementById('session_countdown');
  var stroke = doc.getElementById('countdown_segment');
  var number = doc.getElementById('countdown_number');
  var link = doc.querySelector('.preview-link')
  var segments = 7;
  var i = 0;


  var countDown = function () {
    if ( segments >= 0 ) {
      if ( segments < 7 ) {
        announcer.textContent = segments + ' days left to sign up.';
        link.setAttribute('aria-label', segments + ' days left to sign up now');
      }

      segments = segments--;
      number.textContent = segments--;
      stroke.classList.add('ellapsed-' + i);
      stroke.classList.remove('ellapsed-' + (i-1));
      i++;

      setTimeout(function () {
        announcer.textContent = ' ';
      }, 300)
    }
  }
  setInterval(countDown, 8000)

})(document, window);
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console