javaScript Clock

        JavaScript clock by @Shibasundar Patra





Source Code:-


<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>clock</title>
    <style>
        * {
            margin0;
            padding0;
            box-sizingborder-box;
        }

        body {
            displayflex;
            justify-contentcenter;
            align-itemscenter;
            min-height100vh;
            background#091921;
        }

        .clock {
            width350px;
            height350px;
            displayflex;
            justify-contentcenter;
            align-itemscenter;
            backgroundurl(https://1.bp.blogspot.com/
-qDTFI4SDMrk/X37DG61wIaI/AAAAAAAAAOc/
UGKcLC-eL-YAtuEpQ97OX9NadI99VkY7wCLcBGAsYHQ/s400/clock.png);
            background-sizecover;
            border4px solid #091921;
            border-radius50%;
            box-shadow0 -15px 15px rgba(2552552550.05),
                inset 0 -15px 15px rgba(2552552550.05),
                0 15px 15px rgba(0000.3),
                inset 0 15px 15px rgba(0000.3);
        }

        .clock::before {
            content"";
            positionabsolute;
            width15px;
            height15px;
            background#fff;
            border-radius50%;
            z-index10000;
        }

        .clock .hour,
        .clock .min,
        .clock .sec {
            positionabsolute;
        }

        .clock .hour,
        .hr {
            width160px;
            height160px;
        }

        .clock .min,
        .mn {
            width190px;
            height190px;
        }

        .clock .sec,
        .sc {
            width230px;
            height230px;
        }

        .hr,
        .mn,
        .sc {
            displayflex;
            justify-contentcenter;
            /* align-items: center; */
            positionabsolute;
            border-radius50%;
        }

        .hr:before {
            content"";
            positionabsolute;
            width8px;
            height80px;
            background#ff105e;
            z-index10;
            border-radius6px 6px 0 0;

        }

        .mn:before {
            content"";
            positionabsolute;
            width4px;
            height90px;
            background#fff;
            z-index11;
            border-radius6px 6px 0 0;

        }

        .sc:before {
            content"";
            positionabsolute;
            width2px;
            height150px;
            background#fff;
            z-index12;
            border-radius6px 6px 0 0;

        }

        .footer {
            colorwhite;
            text-alignright;
            font-size10px;
            margin-left200px;
            displayflex;
            flex-wrapwrap;
            flex-directioncolumn;
            justify-contentbaseline;
        }
    </style>
</head>

<body>

    <div class="clock">
        <div class="hour">
            <div class="hr" id="hr"></div>
        </div>
        <div class="min">
            <div class="mn" id="mn"></div>
        </div>
        <div class="sec">
            <div class="sc" id="sc"></div>
        </div>
    </div>
    <div class="footer">
        <h1>Clock Created by @Shibasundar Patra</h1>
    </div>

    <script type="text/javascript">
        const deg = 6;
        const hr = document.querySelector('#hr');
        const mn = document.querySelector('#mn');
        const sc = document.querySelector('#sc');

        setInterval(() => {
            let day = new Date();
            let hh = day.getHours() * 30;
            let mm = day.getMinutes() * deg;
            let ss = day.getSeconds() * deg;

            hr.style.transform = `rotateZ(${(hh) + (mm / 12)}deg)`;
            mn.style.transform = `rotateZ(${mm}deg)`;
            sc.style.transform = `rotateZ(${ss}deg)`;
        })
    </script>
</body>

</html>

Post a Comment

0 Comments