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

              
                <body>
  <div class="clock"></div>
</body>

              
            
!

CSS

              
                .analog-clock {
    border: solid #D3D3D3;
    background-color:#FFEFD5;
    border-radius:100%;
    box-shadow:inset 0 0 2em #808080,0 0 2em black;
    position:relative;
    margin: 2em auto;
}

.analog-clock .center {
    top:48.5%;
    left:48.5%;
    width:3%;
    height:3%;
    background:#D3D3D3;
    border-radius:100%;
    box-shadow:inset 0 0 .5em #808080;
    position:absolute;
    z-index:99;
}

.analog-clock .sec {
    top:10%;
    left:49.75%;
    height:40%;
    width: 0.5%;
    background-color:#F08080;
    box-shadow:0 0 .1em #808080;

    -o-transform-origin: bottom;
    -moz-transform-origin: bottom;
    -ms-transform-origin: bottom;
    -webkit-transform-origin: bottom;
    transform-origin: bottom;

    position:absolute;
    z-index:90;
}

.analog-clock .sec:after {
    content:"";
    height:20%;
    width:100%;
    top:100%;
    background-color:#F08080;
    box-shadow:0 0 .1em #808080;
    position:absolute;
}

.analog-clock .min {
    top:10%;
    left:49.2%;
    height:40%;
    width: 1.6%;
    background-color:#D3D3D3;
    border-radius:.5em;
    box-shadow:inset 0 0 .2em #808080;

    -o-transform-origin:bottom;
    -moz-transform-origin:bottom;
    -ms-transform-origin:bottom;
    -webkit-transform-origin:bottom;
    transform-origin:bottom;

    position:absolute;
    z-index:80;
}

.analog-clock .min:after {
    content:"";
    height:20%;
    width:100%;
    top:100%;
    border-radius:.5em;
    box-shadow:inset 0 0 .2em #808080;
    background-color:#D3D3D3;
    position:absolute;
}

.analog-clock .hour {

    left:49.2%;
    top:25%;
    height:25%;
    width: 1.6%;
    background:#D3D3D3;
    border-radius:.5em;

    box-shadow:inset 0 0 .2em #808080;

    -o-transform-origin: bottom;
    -moz-transform-origin: bottom;
    -ms-transform-origin: bottom;
    -webkit-transform-origin: bottom;
    transform-origin:  bottom;

    position:absolute;
    z-index:70;
}

.analog-clock .hour:after {
    content:"";
    height:30%;
    width:100%;
    top:100%;
    border-radius:.5em;
    box-shadow:inset 0 0 .2em #808080;
    background-color:#D3D3D3;
    position:absolute;
}



.analog-clock .text-late {
    font-family:cursive;
    font-style:italic;
    position: absolute;
    top: 28%;
    width: 100%;
    text-align: center;

}

.analog-clock .text-whatever {
    font-family:sans-serif;
    font-weight:700;
    text-shadow:0 0 .05em #808080;
    position: absolute;
    top: 15%;
    width: 100%;
    text-align: center;
}

.analog-clock .text {
    top:4em;
    width:100%;
    line-height:1.5em;
    text-align:center;
    opacity:0.8;
    position:absolute;
    z-index:1;
}

.analog-clock .numbers {
    bottom:0;
    left:0;
    height:50%;
    width:100%;
    /*border-radius: 100%;*/
    border-bottom-left-radius:50% 100%;
    border-bottom-right-radius:50% 100%;
    float: left;
    opacity:0.8;
    position:absolute;
    z-index:1;
}

.analog-clock .abs {
    font-size:270%;
    font-family: sans-serif;
    text-shadow:0 0 .05em #808080;
    position:absolute;

}

              
            
!

JS

              
                $(document).ready(function() {

    $.fn.extend({
        analogClock: function(size) {
            if (isNaN(size) || size === 0) {
                size = 320;
            }

            //clock size
            var clock = $('<div class="analog-clock"></div>').css({"width": size, "height": size, "border-width": size * 0.04});
            var elemAarray = [];

            //font size
            var textWhatever = {"font-size": size * 0.1375};
            var textLate = {"font-size": size * 0.06};

            //numbers pos and rotation
            var numbers_pos_top = ["70%", "35%", "65%", "55%", "70%", "50%", "57%", "40%", "55%", "45%", "30%", "55%"];
            var numbers_pos_left = ["50%", "80%", "60%", "55%", "35%", "20%", "40%", "75%", "30%", "40%", "10%", "65%"];
            var numbers_deg = [30, 95, 140, 10, 75, 50, 12, 12, 156, 130, 123, 130];

            // create clock components
            elemAarray.push($('<div class="text-whatever">Whatever!</div>').css(textWhatever));
            elemAarray.push($('<div class="text-late">I\'m late anyway ...</div>').css(textLate));
            elemAarray.push($('<div class="min"></div>'));
            elemAarray.push($('<div class="sec"></div>'));
            elemAarray.push($('<div class="hour"></div>'));
            elemAarray.push($('<div class="center"></div>'));

            //generate numbers inside div.numbers and append it to clock
            var num = $('<div class="numbers"></div>');
            for (var i = 0; i < 12; i++) {
                var deg = Math.floor(Math.random() * 360);
                var n = $('<div class="abs">' + (i + 1) + '</div>').css({"top": numbers_pos_top[i], "right": numbers_pos_left[i], 'transform': 'rotate(' + numbers_deg[i] + 'deg)', "font-size": size * 0.125});
                n.appendTo(num);
            }
            elemAarray.push(num);

            for (var i = 0; i < elemAarray.length; i++) {
                elemAarray[i].appendTo(clock);
            }
            this.append(clock);

            //anuimate
            setInterval(function() {
                var date = new Date();
                var seconds = date.getSeconds() * 6;
                var minutes = (date.getMinutes() + (date.getSeconds() / 60)) * 6;
                var hours = (date.getHours() + (date.getMinutes() / 60) + (date.getSeconds() / 3600)) * 30;
                if (hours >= 12) {
                    hours -= 12;
                }

                $('.analog-clock .sec').css({'transform': 'rotate(' + seconds + 'deg)'});
                $('.analog-clock .min').css({'transform': 'rotate(' + minutes + 'deg)'});
                $('.analog-clock .hour').css({'transform': 'rotate(' + hours + 'deg)'});
            }, 1000);

        }
    });

    $('.clock').analogClock(400);
});
              
            
!
999px

Console