Pen Settings

HTML

CSS

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

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

Behavior

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.

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

              
                <svg version="1.1" viewBox="0 0 400 400" preserveAspectRatio="xMidYMax meet">
	<defs>
		<mask id="mask60s">
      <circle class="markers mask" cx="200" cy="200" r="160"/>
    </mask>
  </defs>
  <circle class="markers five" cx="200" cy="200" r="175"/>
	<circle class="markers sixty" cx="200" cy="200" r="160" mask="url(#mask60s)"/>
  <text class="hours minutes" x="200" y="200" dx="8"></text>
  <text class="seconds" x="200" y="300" dx="8"></text>
</svg>
              
            
!

CSS

              
                $basecolor: #f04;
$pi: 3.14159265359;
$radius60: 160;
$radius5: 175;
$circumference60: 2 * $pi * $radius60;
$circumference5: 2 * $pi * $radius5;

@font-face {
  font-family: dotmatrix;
  src: url(//rocktreff.de/dotrice.regular.otf);
}

body { background-color: black; }

svg {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  font-family: dotmatrix;
  
  .markers {
    fill: none;
    stroke: $basecolor;
    stroke-width: 7;
    stroke-linecap: round;
    stroke-linejoin: bevel;
  }
  .five  {
    stroke-dasharray: 0, $circumference5/12;
  }
  .sixty {
    stroke-dasharray: 0, $circumference60/60;
  }
  
	.mask {
    stroke: white;
		stroke-dasharray: $circumference60;
    // silly transformation because of lazyness <:
    transform: rotateZ(-90deg);
    transform-origin: center;
    // magic
    @keyframes offset {
      from { stroke-dashoffset: $circumference60 + $circumference60/120; }
      to   { stroke-dashoffset: 0; }
    }
		animation: offset 60s linear infinite;
	}
  
  .hours.minutes, .seconds {
    fill: $basecolor;
    font-size: 62pt;
    font-family: dotmatrix, sans-serif;
    text-anchor: middle;
    letter-spacing: -0.1em; 
  }
}
              
            
!

JS

              
                // inital offsets
const oneSecond = 1000
const now = new Date()
const offsetSeconds =  now.getSeconds()
const offsetMilliSeconds = now.getMilliseconds()
const initialOffset = offsetSeconds + offsetMilliSeconds/oneSecond
// set mask animation delay to account for the inital offset
$( '.markers.mask' )
  .css( 'animation-delay', `-${initialOffset}s` )
// update
const pad = num => `00${num}`.substr( -2 )
const update = () => {
  const now = new Date()
  const hours = now.getHours()
  const minutes = now.getMinutes()
  const seconds = now.getSeconds()
  const time = `${pad( hours )}:${pad( minutes )}` 
  const $time = $( 'svg .hours.minutes' )
  const secs = pad( seconds )
  const $secs = $( 'svg .seconds' )
  if ( time !== $time.html() )
     $time.html( time )
  if ( secs !== $secs.html() )
    $secs.html( secs )
}
// quick update
update()
// then start updating at the right time
setTimeout(
  () => setInterval( update, oneSecond ),
  oneSecond - offsetMilliSeconds
)
              
            
!
999px

Console