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

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

              
                <div class="time">
	<em class="clock"></em>
	<div class="c-block c-block-3"><div class="bl-inner"><span>2</span></div> <span class="etitle etitle-1">дней</span></div>
	<div class="c-block c-block-2"><div class="bl-inner"><span>5</span></div> <span class="etitle etitle-2">часов</span></div>
	<div class="c-block c-block-2"><div class="bl-inner"><span>40</span></div> <span class="etitle etitle-3">минут</span></div>
	<div class="c-block c-block-2"><div class="bl-inner"><span>15</span></div> <span class="etitle etitle-4">секунд</span></div>
</div>
              
            
!

CSS

              
                		.time {
			display:block;
			margin:50px 0 0 -20px;
			padding:0;
			position:relative;
			text-align:center;
			width:420px;
			background-color:#fff;
			}
			.time * {
				vertical-align:top;
				}
			.time p {
				margin:0 0 20px;
				padding:5px;
				text-align:center;
				background-color:#000;
				color:#fff;
				}
			.time ins,
			.time .clock {
				position:relative;
				top:10px;
				width:40px;
				height:55px;
				display:inline-block;
				*display:inline;
				zoom:1;
				background:transparent url(http://novi.co/test/bangaclub/_styles/interface/sprites.png) no-repeat -260px -154px;
				}
			.time ins {
				width:10px;
				}
			.time ins {
				background-position:-300px -154px;
				}
			.time .clock {
				margin-right:7px;
				}
			.c-block {
				display:inline-block;
				*display:inline;
				zoom:1;
				margin:0 18px 0 3px;
				padding:4px 0 40px 3px;
				position:relative;
				background:transparent url(http://novi.co/test/bangaclub/_styles/interface/sprites.png) no-repeat -260px 0;
				}
			.c-block:before {
				content:'';
				position:absolute;
				left:100%;
				top:0;
				width:31px;
				background:transparent url(http://novi.co/test/bangaclub/_styles/interface/sprites.png) no-repeat 100% -77px;
				height:77px;
				}
			.c-block-1 {
				width:20px;
				}
			.c-block-2 {
				width:45px;
				}
			.c-block-3 {
				width:70px;
				}
				.bl-inner {
					position:relative;
					margin-right:-10px;
					height:48px;
					background:transparent url(http://novi.co/test/bangaclub/_styles/interface/sprites.png) no-repeat -5px -48px;
					}
				.bl-inner:before{
					content:'';
					position:absolute;
					left:100%;
					top:0;
					width:3px;
					background:transparent url(http://novi.co/test/bangaclub/_styles/interface/sprites.png) no-repeat -122px -48px;
					height:48px;
					}
					.bl-inner span {
						display:none;
						font-size:46px;
						color:#fff;
						line-height:46px;
						margin-left:2px;
						}
				.time .etitle {
					position:absolute;
					width:110px;
					text-align:center;
					left:50%;
					margin-left:-47px;
					top:55px;
					line-height:30px;
					}
				.etitle-1 {
					font-size:1.6em;
					}
				.etitle-2 {
					font-size:1.37em;
					padding-top:.1em;
					}
				.etitle-3 {
					font-size:1.12em;
					padding-top:.2em;
					}
				.etitle-4 {
					font-size:.87em;
					padding-top:.3em;
					}
              
            
!

JS

              
                $(function() {

    function setCookie(name, value, options) {
        options = options || {};

        var expires = options.expires;

        if (typeof expires == "number" && expires) {
            var d = new Date();
            d.setTime(d.getTime() + expires * 1000);
            expires = options.expires = d;
        }
        if (expires && expires.toUTCString) {
            options.expires = expires.toUTCString();
        }

        value = encodeURIComponent(value);

        var updatedCookie = name + "=" + value;

        for (var propName in options) {
            updatedCookie += "; " + propName;
            var propValue = options[propName];
            if (propValue !== true) {
                updatedCookie += "=" + propValue;
            }
        }

        document.cookie = updatedCookie;
    }

    // возвращает cookie с именем name, если есть, если нет, то undefined
    function getCookie(name) {
        var nameEQ = name + "=";
        var ca = document.cookie.split(';');
        for (var i = 0; i < ca.length; i++) {
            var c = ca[i];
            while (c.charAt(0) == ' ') c = c.substring(1, c.length);
            if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
        }
        return null;
    }

    window.onbeforeunload = function() {

        if (($('#day').text() == 0) & ($('#hour').text() == 0) & ($('#minute').text() == 0) & ($('#seconds').text() == 0)) {

            setCookie("dl", "", {
                expires: -1
            });
            setCookie("hl", "", {
                expires: -1
            });
            setCookie("ml", "", {
                expires: -1
            });
            setCookie("sl", "", {
                expires: -1
            });

        } else {

            setCookie("dl", $('#day').text(), {
                expires: 360
            });
            setCookie("hl", $('#hour').text(), {
                expires: 360
            });
            setCookie("ml", $('#minute').text(), {
                expires: 360
            });
            setCookie("sl", $('#seconds').text(), {
                expires: 360
            });
        }
    }

    var dl = getCookie('dl'),
        hl = getCookie('hl'),
        ml = getCookie('ml'),
        sl = getCookie('sl');

    if (dl) {

        $('#day').text(dl);
        $('#hour').text(hl);
        $('#minute').text(ml);
        $('#seconds').text(sl);
    }

    if (document.createElement('canvas').getContext) {
        var image = $('<img />').load(function() {
            var image = this,
                offset_left = 5,
                offset_number = 4;

            function drawNumberLine(context, position, number, line) {
                context.drawImage(image, number * 25, line, 25, 1, position * 25 + offset_left + offset_number, line, 25, 1);
            }

            function drawNumberBottom(context, position, number) {
                context.drawImage(image, number * 25, 25, 25, 23, position * 25 + offset_left + offset_number, 25, 25, 23);
            }

            function drawNumberTop(context, position, number) {
                context.drawImage(image, number * 25, 0, 25, 23, position * 25 + offset_left + offset_number, 0, 25, 23);
            }

            function cf_draw(from, to, canvas, step) {
                var context = canvas.getContext('2d'),
                    offsets = [{
                        w: 2,
                        h: -2
                    }, {
                        w: 4,
                        h: -5
                    }, {
                        w: 6,
                        h: -9
                    }, {
                        w: 8,
                        h: -14
                    }, {
                        w: 10,
                        h: -20
                    }, {
                        w: 0,
                        h: 0
                    }, {
                        w: 10,
                        h: -20
                    }, {
                        w: 8,
                        h: -14
                    }, {
                        w: 6,
                        h: -9
                    }, {
                        w: 4,
                        h: -5
                    }, {
                        w: 2,
                        h: -2
                    }, {
                        w: 0,
                        h: 0
                    }],
                    width = canvas.width,
                    nwidth = width + offsets[step].w,
                    maxscale = nwidth / width,
                    height = 23,
                    nheight = height + offsets[step].h,
                    scale_y = nheight / height,
                    dig_col = parseInt($(canvas).parents('div.c-block')[0].className.substr(-1), 10);

                from = from.toString();
                to = to.toString();

                while (from.length < dig_col) {
                    from = '0' + from;
                }
                while (to.length < dig_col) {
                    to = '0' + to;
                }

                context.clearRect(0, 0, width, canvas.height);
                context.save();

                for (var j = 0; j <= to.length - 1; j++) {
                    drawNumberTop(context, j, to[j]);
                }

                if (step == 11) {
                    for (var j = 0; j <= to.length - 1; j++) {
                        drawNumberBottom(context, j, to[j]);
                    }
                    return;
                }

                for (var j = 0; j <= from.length - 1; j++) {
                    drawNumberBottom(context, j, from[j]);
                }

                // draw bg
                context.drawImage(image, 0, 96 + step * 48, width - 5, 48, 0, 0, width - 5, 48);
                context.drawImage(image, 125, 96 + step * 48, 4, 48, width - 5, 0, 5, 48);

                for (var i = 0; i < 24; i++) {
                    if (step < 5) {
                        context.setTransform(maxscale - (maxscale - 1) * i / 23, 0, 0, scale_y, -(nwidth - width) / 2 * (1 - i / 23), -offsets[step].h);
                        for (var j = 0; j <= from.length - 1; j++) {
                            drawNumberLine(context, j, from[j], i);
                        }
                    }

                    if (step > 5) {
                        context.setTransform(1 + (maxscale - 1) * i / 23, 0, 0, scale_y, -(nwidth - width) / 2 * (i / 23), -offsets[step].h);
                        for (var j = 0; j <= to.length - 1; j++) {
                            drawNumberLine(context, j, to[j], 25 + i);
                        }
                    }
                    context.restore();
                }
                context.setTransform(1, 0, 0, 1, 0, 0);

                // draw blick
                context.drawImage(image, 130, 96 + step * 48, width - 5, 48, 0, 0, width - 5, 48);
                context.drawImage(image, 255, 96 + step * 48, 4, 48, width - 5, 0, 5, 48);
            }

            function cf_animate(from, to, canvas, step) {
                cf_draw(from, to, canvas, step);
                step++;
                if (step > 11) return;

                setTimeout(function() {
                    cf_animate(from, to, canvas, step);
                }, 50 - 20 * step / 11);
            }

            function seconds(from, canvas) {

                if ($("#day").text() == 0) {
                    if ($("#hour").text() == 0) {
                        if ($("#minute").text() == 0) {
                            if ($("#seconds").text() == 1) {

                                setCookie("dl", "", {
                                    expires: -1
                                });
                                setCookie("hl", "", {
                                    expires: -1
                                });
                                setCookie("ml", "", {
                                    expires: -1
                                });
                                setCookie("sl", "", {
                                    expires: -1
                                });

                                location.reload();
                            }
                        }
                    }
                }

                var to = from - 1;

                $('#seconds').text(to);

                if (from <= 0) {
                    to = 59;

                    $('#seconds').text(to);

                    // minutes animate
                    var minutes_from = parseInt($('span', minutes_cnt).text(), 10);
                    var minutes_to = minutes_from - 1;

                    if (minutes_from <= 0) {
                        minutes_to = 59;

                        // hourses animate
                        var hourses_from = parseInt($('span', hourses_cnt).text(), 10);
                        var hourses_to = hourses_from - 1;

                        if (hourses_from <= 0) {
                            hourses_to = 23;

                            var days_from = parseInt($('span', days_cnt).text(), 10);
                            var days_to = days_from - 1;

                            if (days_from == 0) {
                                return;
                            }
                            cf_animate(days_from, days_to, $('canvas', days_cnt)[0], 0);
                            $('span', days_cnt).text(days_to);
                        }
                        cf_animate(hourses_from, hourses_to, $('canvas', hourses_cnt)[0], 0);
                        $('span', hourses_cnt).text(hourses_to);
                    }

                    cf_animate(minutes_from, minutes_to, $('canvas', minutes_cnt)[0], 0);
                    $('span', minutes_cnt).text(minutes_to);
                }

                cf_animate(from, to, canvas, 0);

                from--;
                if (from < 0) {
                    from = 59;
                }

                setTimeout(function() {
                    seconds(from, canvas);
                }, 1000);
            }

            $('div.bl-inner').each(function() {
                var canvas = $('<canvas></canvas>').css({
                    position: 'absolute',
                    left: -5,
                    top: 0
                }).appendTo(this)[0];

                canvas.width = $(this).width() + offset_left * 2 + 3;
                canvas.height = $(this).height();

                cf_draw(parseInt($('span', this).text(), 10), parseInt($('span', this).text(), 10), canvas, 11);
            });

            var seconds_cnt = $('div.time .bl-inner:last'),
                minutes_cnt = $('div.time .bl-inner:eq(2)'),
                hourses_cnt = $('div.time .bl-inner:eq(1)'),
                days_cnt = $('div.time .bl-inner:eq(0)');

            seconds(parseInt($('span', seconds_cnt).text(), 10), $('canvas', seconds_cnt)[0]);
        });
        image.attr('src', 'http://novi.co/test/bangaclub/_styles/interface/sprites.png');
    } else {
        $('div.bl-inner span').show();
    }
});
              
            
!
999px

Console