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 id="hour" class="barclock">Hours</div>

<div id="minute" class="barclock">Minutes</div>

<div id="second" class="barclock">Seconds</div>

<p>Bar Clock implemented using CSS Variables, with JavaScript used only to update the CSS Variables once per second</p>

<h2>Read Tutorial: <a href="http://www.javascriptkit.com/dhtmltutors/css-variables-tutorial.shtml">Introduction to CSS Variables</a></h2>
  --hourpct: 0; /* value btw 0 to 1 for all 3 vars */
  --minutepct: 0;
  --secondpct: 0;

  border: 1px solid gray;
  margin-bottom: 1em;
  padding: 10px;
  position: relative;
  overflow: hidden;
  font-weight: bold;
  text-transform: uppercase;

  content: '';
  position: absolute;
  background: red;
  width: 100%;
  height: 100%;
  left: -100%;
  top: 0;
  z-index: -1;
  transform: translate3d(0,0,0);

  background: #00b9f1;
  transform: translate3d(calc(var(--hourpct) * 100%),0,0);

  background: #f9c00c;
  transform: translate3d(calc(var(--minutepct) * 100%),0,0);

  background: #75D701;
  transform: translate3d(calc(var(--secondpct) * 100%),0,0);
              var hourbar = document.getElementById('hour')
var minutebar = document.getElementById('minute')
var secondbar = document.getElementById('second')

  var today = new Date()
  var curhour = today.getHours()
  var curminute = today.getMinutes()
  var cursecond = today.getSeconds()
  hourbar.style.setProperty('--hourpct', curhour/24)
  minutebar.style.setProperty('--minutepct', curminute/60)
  secondbar.style.setProperty('--secondpct', cursecond/60)
}, 1000)

Loading ..................