Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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

              
                <!--
  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.
-->
              
            
!

CSS

              
                *,
*: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;
}
              
            
!

JS

              
                (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

Console