cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

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="b c outer">
    <noscript>
        <div class="b c" style="color:red;font-size:24px">This clock needs JavaScript</div>
    </noscript>
    <div class="b c circle" id="off">        
        <div class="b n">
            <span class="b ib tn">7</span>
            <span class="b ib tn">1</span>
        </div>
        <div class="b n">            
            <span class="b ib tn">8</span>
            <span class="b ib tn">2</span>
        </div>
        <div class="b n">
            <span class="b ib tn">9</span>
            <span class="b ib tn">3</span>
        </div>
        <div class="b n">
            <span class="b ib tn">10</span>
            <span class="b ib tn">4</span>
        </div>
        <div class="b n">
            <span class="b ib tn">11</span>
            <span class="b ib tn">5</span>
        </div>
        <div class="b n">
            <span class="b ib tn">12</span>
            <span class="b ib tn">6</span>
        </div>
        <div class="b c needle short" id="hour"></div>
        <div class="b c needle medium" id="minute"></div>
        <div class="b c needle long" id="second">
            <div class="b c pivot"></div>
        </div>
        <div class="b c br">CLOCK</div>
    </div>
    <p class="b c dn" id="note"><small>Click clock to mute.</small></p>    
</div>
            
          
!
            
              /*static 300px x 300px of dimensions*/
body {
    background: tan;
    padding: 10px 0;
    background-color: tan;
    background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIHZpZXdCb3g9IjAgMCAxIDEiIHByZXNlcnZlQXNwZWN0UmF0aW89Im5vbmUiPgo8cmFkaWFsR3JhZGllbnQgaWQ9Imc4MjciIGdyYWRpZW50VW5pdHM9InVzZXJTcGFjZU9uVXNlIiBjeD0iNTAlIiBjeT0iMCUiIHI9Ijc1JSI+CjxzdG9wIHN0b3AtY29sb3I9IiNkMmQ0OGMiIG9mZnNldD0iMCIvPjxzdG9wIHN0b3AtY29sb3I9IiNkMmI0OGMiIG9mZnNldD0iMSIvPgo8L3JhZGlhbEdyYWRpZW50Pgo8cmVjdCB4PSItNTAiIHk9Ii01MCIgd2lkdGg9IjEwMSIgaGVpZ2h0PSIxMDEiIGZpbGw9InVybCgjZzgyNykiIC8+Cjwvc3ZnPg==);
    background-repeat: repeat-x;
    background-position: top center;
    height: 320px;
}
.b {
    padding: 0;
    margin: 0;
    box-sizing: border-box;
    font-size: 16px;
    color: #000;
    font-family: consolas, monaco, menlo, courier, monospace;
    border: 0;
    line-height: normal;
}

.c {
    text-align: center;
    margin: auto;
}

.ib {
    display: inline-block;
}
.circle {
    height: 300px;
    width: 300px;
    border: 10px solid #333;
    background-color: #ddd;
    background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIHZpZXdCb3g9IjAgMCAxIDEiIHByZXNlcnZlQXNwZWN0UmF0aW89Im5vbmUiPgo8cmFkaWFsR3JhZGllbnQgaWQ9ImczNzMiIGdyYWRpZW50VW5pdHM9InVzZXJTcGFjZU9uVXNlIiBjeD0iNTAlIiBjeT0iNTAlIiByPSIyMDAlIj4KPHN0b3Agc3RvcC1jb2xvcj0iI0ZGRkZGRiIgb2Zmc2V0PSIwIi8+PHN0b3Agc3RvcC1jb2xvcj0iIzg4OCIgb2Zmc2V0PSIxIi8+CjwvcmFkaWFsR3JhZGllbnQ+CjxyZWN0IHg9Ii01MCIgeT0iLTUwIiB3aWR0aD0iMTAxIiBoZWlnaHQ9IjEwMSIgZmlsbD0idXJsKCNnMzczKSIgLz4KPC9zdmc+);
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 20px;
    overflow: hidden;
    display: none;
    transition: border-radius 0.25s;
}
.n {
    position: absolute;
    width: 280px;
    height: 22px;    
    margin-top: 129px;
    transform-origin: center center;
    z-index: 2;
}
.br {
    position: absolute;
    margin-top: 80px;
    margin-left: 85px;
    font-size: 24px;
    width: 100px;
    color: #bbb;
    text-shadow: 1px 1px 2px #fff;
}
.dn {
    display: none;
    margin-top: 10px;
}
.n:first-child {
    transform: rotate(-60deg)
}
.n:first-child > .tn {
    transform: rotate(60deg);
}
.n:nth-child(2) {
    transform: rotate(-30deg)
}
.n:nth-child(2) > .tn {
    transform: rotate(30deg);
}
.n:nth-child(3) {
    transform: rotate(0)
}
.n:nth-child(3) > .tn {
    transform: rotate(0deg);
}
.n:nth-child(4) {
    transform: rotate(30deg)
}
.n:nth-child(4) > .tn {
    transform: rotate(-30deg);
}
.n:nth-child(5) {
    transform: rotate(60deg)
}
.n:nth-child(5) > .tn {
    transform: rotate(-60deg);
}
.n:nth-child(6) {
    transform: rotate(90deg)
}
.n:nth-child(6) > .tn {
    transform: rotate(-90deg);
}
.tn {
    float: right;
    text-shadow: 1px 1px 2px #fff;
    color: #888;
    padding: 4px;
    height: 22px;
    width: 22px;
    font-size: 12px;
    border-radius: 50%;
    transform-origin: center center;
}
.tn:first-of-type {
    float: left;
}
.needle {
    position: absolute;
    height: 4px;
    background: #333;
    border-radius: 100% 5px 5px 100%;
    width: 145px;
    margin-top: 138px;
    margin-left: 12px;
    transform-origin: 128px 50%;
    background: brown;
    z-index: 5;
}
.medium {
    height: 8px;
    width: 120px;
    margin-top: 136px;
    margin-left: 37px;    
    background: rosybrown;
    z-index: 4;
    transform-origin: 102px 50%;
}
.short {
    height: 10px;
    width: 100px;
    margin-top: 136px;
    margin-left: 57px;
    background: #333;
    transform-origin: 83px 50%;
    z-index: 3;
}
.pivot {
    height: 16px;
    width: 16px;
    border-radius: 50%;
    border: 4px solid brown;
    background: #fff;
    position: relative;
    float: right;
    right: 10px;
    top: -6px;
    box-shadow: 0 0 4px #000 inset;
}
.circle:hover {
    cursor: pointer;
    border-radius: 50%;
}
            
          
!
            
              $(function () {
    "use strict";
    var $sec = $("#second");
    var $min = $("#minute");
    var $hour = $("#hour");
    // This is the audio in base64 URI
    // Tool for conversion: http://portraptor.johanpaul.net/2016/05/base64-audiovideo-converter.html
    var uso = "data:audio/mp3;base64,SUQzAwAAAAAfdlBSSVYAAAAOAABQZWFrVmFsdWUA/n8AAFBSSVYAAAARAABBdmVyYWdlTGV2ZWwAkicAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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uvHxxE8hZWRIc0qGWbjG49VCk1v955fLVkHQFPK+Isi3Cgdyvhzlixv///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////qTRMOQjIAC1CZLYe9KWkSkCU0x6UgAAAEuAAAAIAAAJcAAAAT///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP/6k0R6YfqAC5AAS4AAAAgAAAlwAAABAAABLgAAACAAACXAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABUQUcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgDA==";
    var audio;
    var ct = -1;
    function run(e) {
        // This one is the clock value from your computer's time n date
        function getTime() {
            var today = new Date();
            var h = today.getHours();
            var m = today.getMinutes();
            var s = today.getSeconds();
            return [h, m, s];
        }
        function needleAnimation() {
            // Init the clock display
            if ($("#off").css("display") === "none") {
                $("#off").fadeIn(300, function () {
                    if (!e && $("#note").css("display") === "none") {
                        $("#note").fadeIn(300);
                    }
                });
            }
            var time = getTime();
            if (!e) { // Run with audio
                ct += 1; // ct is the index of created "Audio" object
                if (ct > 4) {
                    ct = 0;
                }
                audio[ct].play();
            }
            var s_value = time[2] * 6 + 90;
            var m_value = time[1] * 6 + 90;
            var h_value = (time[0] % 12) * 30 + 90 + (time[1] / 60) * 30;
            var secS = ((Math.cos(s_value / 180 * Math.PI)) * 3) + "px " + ((Math.sin(s_value / 180 * Math.PI)) * 3) + "px 3px rgba(0, 0, 0, 0.25)";
            var minS = ((Math.cos(m_value / 180 * Math.PI)) * 2) + "px " + ((Math.sin(m_value / 180 * Math.PI)) * 2) + "px 2px rgba(0, 0, 0, 0.8)";
            // This is for the needles rotation
            $sec.css({transform: "rotate(" + s_value + "deg)", "box-shadow": secS});
            $min.css({transform: "rotate(" + m_value + "deg)", "box-shadow": minS});
            $hour.css({transform: "rotate(" + h_value + "deg)"});
        }
        // 1000 ms = 1 s interval period
        setInterval(needleAnimation, 1000);
    }
    // For mute and changing the color
    function clickOff() {
        function turnOn(v) {
            v.volume = 0.2;
        }
        function turnOff(v) {
            v.volume = 0;
        }
        if (audio[0].volume === 0) {
            audio.forEach(turnOn);
            $("#off").css({
                "background-image": "url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIHZpZXdCb3g9IjAgMCAxIDEiIHByZXNlcnZlQXNwZWN0UmF0aW89Im5vbmUiPgo8cmFkaWFsR3JhZGllbnQgaWQ9ImczNzMiIGdyYWRpZW50VW5pdHM9InVzZXJTcGFjZU9uVXNlIiBjeD0iNTAlIiBjeT0iNTAlIiByPSIyMDAlIj4KPHN0b3Agc3RvcC1jb2xvcj0iI0ZGRkZGRiIgb2Zmc2V0PSIwIi8+PHN0b3Agc3RvcC1jb2xvcj0iIzg4OCIgb2Zmc2V0PSIxIi8+CjwvcmFkaWFsR3JhZGllbnQ+CjxyZWN0IHg9Ii01MCIgeT0iLTUwIiB3aWR0aD0iMTAxIiBoZWlnaHQ9IjEwMSIgZmlsbD0idXJsKCNnMzczKSIgLz4KPC9zdmc+)",
                "background-color": "#ddd"
            });
            $("#note").html("<small>Click clock to mute.</small>");
            $(".tn").css("color", "#888");
        } else {
            audio.forEach(turnOff);
            $("#off").css({
                "background-image": "url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIHZpZXdCb3g9IjAgMCAxIDEiIHByZXNlcnZlQXNwZWN0UmF0aW89Im5vbmUiPgo8cmFkaWFsR3JhZGllbnQgaWQ9Imc1MTUiIGdyYWRpZW50VW5pdHM9InVzZXJTcGFjZU9uVXNlIiBjeD0iNTAlIiBjeT0iNTAlIiByPSI1MCUiPgo8c3RvcCBzdG9wLWNvbG9yPSIjRkZGRkZGIiBvZmZzZXQ9IjAiLz48c3RvcCBzdG9wLWNvbG9yPSIjODdjZWZhIiBvZmZzZXQ9IjEiLz4KPC9yYWRpYWxHcmFkaWVudD4KPHJlY3QgeD0iLTUwIiB5PSItNTAiIHdpZHRoPSIxMDEiIGhlaWdodD0iMTAxIiBmaWxsPSJ1cmwoI2c1MTUpIiAvPgo8L3N2Zz4=)",
                "background-color": "lightskyblue"
            });
            $("#note").html("<small style='color:brown;letter-spacing:1px;font-weight:bold;'>MUTED</small>");
            $(".tn").css("color", "#555");
        }
    }
    /*
    ABOUT REPEATEDLY PLAYING AUDIO
    ---------------------------
    A. Using audio file:
    ---------------------
    1. The trick to play over and over the same (short) audio is to create more than 1 "Audio" object. Then repeat the play() invocation for each different object.
    2. Or use 1 object, attach a listener (ended event), then chain that to your other trigger if the app something stuff nanana. This one is less efficient. You'll have no "buffer".
    ---------------------
    B. Using web audio API:
    ---------------------
    Synthesize it using web audio API. That takes superposition of multifrequency, phase and oscillation types and maybe filter(s) to mimic the ticking sound. Boy that's something.
    */
    (function () {
        var i = 0;
        if (Audio !== undefined) {
            audio = new Audio(uso);
            if (audio.canPlayType("audio/mp3") !== "") {
                $("#off").click(clickOff); // Muting trigger
                audio = [];
                // Here, I create 5 "Audio" objects
                while (i < 5) {
                    audio.push(new Audio(uso));
                    audio[i].volume = 0.2;
                    i += 1;
                }
                run(0); // Run with audio
            } else {
                run(1); // Run without audio
            }
        } else {
            run(1); // Run without audio
        }
    }());
});
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

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

Console