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

              
                 <!-- Clock container -->
    <div class="clock">
        <div class="clock-face">
            <!-- Logo -->
            <div class="logo">MYCSLAB</div>
            <!-- Clock hands -->
            <div class="hand hour-hand"></div>
            <div class="hand min-hand"></div>
            <div class="hand second-hand"></div>
        </div>
    </div>
              
            
!

CSS

              
                  /* Global styles */
        html {
            background: #018DED;
            background-size: cover;
            font-family: 'helvetica neue', sans-serif;
            text-align: center;
            font-size: 10px;
        }

        body {
            margin: 0;
            font-size: 2rem;
            display: flex;
            flex: 1;
            min-height: 100vh;
            align-items: center;
        }

        /* Clock container styles */
        .clock {
            width: 30rem;
            height: 30rem;
            border-radius: 50%;
            margin: 50px auto;
            position: relative;
            padding: 100px;
            background: url("https://www.watchuseek.com/attachments/5342170/");
            background-size: cover;
            box-shadow: 
                0 0 0 4px rgba(0,0,0,0.1),
                20px 30px 50px rgba(0,0,0,0.5);
        }

        /* Clock face styles */
        .clock-face {
            position: relative;
            width: 100%;
            height: 100%;
            transform: translateY(-3px); /* Adjust for the height of clock hands */
        }

        /* Clock hand styles */
        .hand {
            width: 50%;
            height: 6px;
            background: red;
            position: absolute;
            top: 50%;
            transform-origin: 100%;
            transform: rotate(90deg);
            transition: all 0.05s linear;
        }

        /* Logo styles */
        .logo {
            position: absolute;
            background: #000;
            padding: 0px 5px;
            font-size: 30px;
            top: 50px;
            left: 70px;
            color: #fff;
            border-radius: 10px;
        }

/* media query */
  @media screen and (max-width: 768px) {
           .clock {
            width:12rem;
            height:12rem;
        }
  
           .logo {     
           font-size: 20px;
           top: 0px;
           left: 10px;}
        }


        @media screen and (max-width: 380px) {
           .clock {
            width:12rem;
            height:12rem;
        }
  
           .logo {     
           font-size: 20px;
           top: 0px;
           left: 10px;}
        }
              
            
!

JS

              
                        // Select clock hand elements
        const secondHand = document.querySelector('.second-hand');
        const minsHand = document.querySelector('.min-hand');
        const hourHand = document.querySelector('.hour-hand');

        function setDate() {
            const now = new Date();

            // Update second hand
            const seconds = now.getSeconds();
            const secondsDegrees = ((seconds / 60) * 360) + 90; // Convert to degrees, add 90 to offset default position
            secondHand.style.transform = `rotate(${secondsDegrees}deg)`;

            // Update minute hand
            const mins = now.getMinutes();
            const minsDegrees = ((mins / 60) * 360) + ((seconds/60)*6) + 90; // Include seconds for smoother movement
            minsHand.style.transform = `rotate(${minsDegrees}deg)`;

            // Update hour hand
            const hour = now.getHours();
            const hourDegrees = ((hour / 12) * 360) + ((mins/60)*30) + 90; // Include minutes for smoother movement
            hourHand.style.transform = `rotate(${hourDegrees}deg)`;
        }

        // Update clock every second
        setInterval(setDate, 1000);

        // Initial call to set clock hands
        setDate();

              
            
!
999px

Console