这个页面实现了一个展示多种设计风格时钟的博物馆,每个时钟都有独特的视觉效果。页面使用了 CSS 和 JavaScript 来实现时钟的动态效果和交互功能。


大家复制代码时,可能会因格式转换出现错乱,导致样式失效。建议先少量复制代码进行测试,若未能解决问题,私信回复源码两字,我会发送完整的压缩包给你。

演示效果

HTML&CSS:全网最全的代码时钟效果

HTML&CSS


html>
html lang="en">

head>
    meta charset="UTF-8">
    meta http-equiv="X-UA-Compatible" content="IE=edge">
    meta name="viewport" content="width=device-width, initial-scale=1.0">
    script src="https://code.jquery.com/jquery-3.6.0.min.js">script>
    title>Documenttitle>
    style>
        @import url("https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap");

        body {
            background#f5f5f5;
            min-height100vh;
            margin0;
            padding40px 0;
            font-family"Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji""Segoe UI Emoji""Segoe UI Symbol";
            color#333;
        }

        h1 {
            font-weight600;
            font-size2.5rem;
            color#101828;
            text-align: center;
            display: block;
            margin-top1em;
            margin-bottom1em;
            font-weight: bold;
        }

        .container {
            display: flex;
            gap40px;
            padding20px;
            flex-direction: row;
            flex-wrap: wrap;
            align-items: center;
            justify-content: center
        }

        .card {
            background: white;
            border-radius24px !important;
            /* padding: 30px; */
            box-shadow0 10px 30px rgba(0000.1);
            text-align: center;
            position: relative;
            width356px;
            height426px;
            display: flex;
            align-items: center;
            justify-content: center
        }

        .card::after {
            contentattr(data-description);
            position: absolute;
            bottom0;
            left0;
            right0;
            background#F5F5F5;
            backgroundlinear-gradient(0deg, rgba(24524524510%rgba(2452452450.839%rgba(2552552550100%);
            color#191919;
            padding30px;
            font-size1rem;
            line-height1.5;
            opacity0;
            transition: opacity 0.3s ease;
            pointer-events: none;
            z-index12;
            heightcalc(100% - 60px);
            border-radius24px;
            display: flex;
            align-items: center;
            justify-content: center;
            backdrop-filterblur(8px);
        }

        .card:hover::after {
            opacity1;
        }

        .card h2 {
            margin-top0;
            margin-bottom8px;
            color#333;
            font-weight500;
            position: absolute;
            top40px;
            left0;
            text-align: center;
            width100%;
            display: block;
            z-index99
        }

        .card p {
            margin-top0;
            margin-bottom20px;
            color#666;
            font-size14px;
        }

        .clock-container {
            position: relative;
            width280px;
            height280px;
            margin0 auto;
            display: flex;
            align-items: center;
            justify-content: center;
            margin-top40px
        }

        .clock-face {
            position: absolute;
            width280px;
            height280px;
            border-radius50%;
        }

        .hour-marks {
            position: absolute;
            width100%;
            height100%;
        }

        .hour-mark {
            position: absolute;
            left50%;
            transform-origin0 140px;
        }

        .minute-mark {
            position: absolute;
            left50%;
            transform-origin0 140px;
        }

        .hour-number {
            position: absolute;
            text-align: center;
            transform-origin: center;
        }

        .hand {
            position: absolute;
            transform-origin: bottom center;
            bottom140px;
            left140px;
        }

        .skeuomorphic {
            background#F5F5F5;
            backgroundlinear-gradient(140deg, rgba(24524524510%rgba(230230230150%rgba(2142142141100%);
        }

        .skeuomorphic .clock-container {
            backgroundlinear-gradient(135deg, #f5f5f5 0%, #e0e0e0 100%);
            box-shadowrgba(0000.070px 1px 2pxrgba(0000.070px 2px 4pxrgba(0000.070px 4px 8pxrgba(0000.070px 8px 16pxrgba(0000.070px 16px 32pxrgba(0000.070px 32px 64px0 2px 5px rgba(0000.3);
            border8px solid #fff;
            border-radius50%;
        }

        .skeuomorphic .clock-face {
            backgroundlinear-gradient(135deg, #f5f5f5 0%, #e0e0e0 100%);
            box-shadow0 0 10px rgba(0000.2), inset 0 0 20px rgba(0000.1),
                0 2px 5px rgba(0000.3);

        }

        .skeuomorphic .clock-reflection {
            position: absolute;
            width260px;
            height130px;
            top20px;
            left10px;
            border-radius130px 130px 0 0;
            backgroundlinear-gradient(to bottom,
                    rgba(2552552550.60%,
                    rgba(2552552550100%);
            pointer-events: none;
            z-index11;
        }

        .skeuomorphic .clock-center {
            position: absolute;
            width14px;
            height14px;
            background#333;
            border-radius50%;
            top133px;
            left133px;
            box-shadow0 0 5px rgba(0000.5);
            z-index10;
        }

        .skeuomorphic .clock-center::after {
            content"";
            position: absolute;
            width6px;
            height6px;
            background#888;
            border-radius50%;
            top4px;
            left4px;
        }

        .skeuomorphic .hour-mark {
            width4px;
            height12px;
            background#333;
            margin-left: -2px;
        }

        .skeuomorphic .minute-mark {
            width2px;
            height6px;
            background#666;
            margin-left: -1px;
        }

        .skeuomorphic .hour-number {
            font-size24px;
            font-weight500;
            color#333;
            width40px;
            height40px;
            line-height40px;
        }

        .skeuomorphic .hour-hand {
            width8px;
            height75px;
            background#333;
            border-radius10px 10px 0 0;
            box-shadow2px 0px 7px rgba(0000.5);
            z-index7;
            margin-left: -4px;
        }

        .skeuomorphic .minute-hand {
            width6px;
            height105px;
            background#444;
            border-radius10px 10px 0 0;
            box-shadow2px 0px 6px rgba(0000.5);
            z-index8;
            margin-left: -3px;
        }

        .skeuomorphic .second-hand {
            width2px;
            height115px;
            background#c00;
            box-shadow2px 0px 5px rgba(0000.5);
            z-index9;
        }

        .skeuomorphic .clock-bezel {
            position: absolute;
            width290px;
            height290px;
            top: -5px;
            left: -5px;
            border-radius50%;
            backgroundlinear-gradient(135deg, #d0d0d0 0%, #f8f8f8 100%);
            z-index: -1;
        }

        .flat-design {
            background#f2f2f7
        }

        .flat-design .clock-face {
            background#ffffff;
            border3px solid #191919
        }

        .flat-design .clock-center {
            position: absolute;
            width12px;
            height12px;
            background#ffcd50;
            border-radius50%;
            top134px;
            left134px;
            z-index10;
        }

        .flat-design .hour-mark {
            width3px;
            height10px;
            background#555;
        }

        .flat-design .minute-mark {
            width2px;
            height8px;
            background#bcbcbc;
        }

        .flat-design .hour-number {
            font-size24px;
            font-weight400;
            color#555;
            width40px;
            height40px;
            line-height40px;
        }

        .flat-design .hour-hand {
            width6px;
            height70px;
            background#555;
            z-index7;
            margin-left: -3px;
        }

        .flat-design .minute-hand {
            width4px;
            height95px;
            background#777;
            z-index8;
            margin-left: -2px;
        }

        .flat-design .second-hand {
            width2px;
            height110px;
            background#ffcd50;
            z-index9;
        }

        .material-design {
            background#EDE7F6;
        }

        .material-design .clock-face {
            background#512da8;
            box-shadowrgba(0000.30px 19px 38pxrgba(0000.220px 15px 12px;
        }

        .material-design .clock-face-inner {
            width62%;
            height62%;
            border-radius50%;
            background#7E57C2;
            box-shadowrgba(0000.250px 14px 28pxrgba(0000.220px 10px 10px;
            z-index2;
            display: flex;
            align-items: center;
            justify-content: center
        }

        .material-design .clock-center {
            position: absolute;
            width12px;
            height12px;
            background#f44336;
            border-radius50%;
            top134px;
            left134px;
            box-shadow0 1px 3px rgba(0000.12);
            z-index10;
        }

        .material-design .hour-number {
            font-size20px;
            font-weight500;
            color#EDE7F6;
            width40px;
            height40px;
            line-height40px;
            text-shadowrgba(0000.190px 10px 20pxrgba(0000.230px 6px 6px;
        }

        .material-design .hour-hand {
            width6px;
            height60px;
            background#fff;
            border-radius4px;
            z-index7;
            margin-left: -2px;
            box-shadowrgba(0000.190px 10px 20pxrgba(0000.230px 6px 6px;
        }

        .material-design .minute-hand {
            width6px;
            height98px;
            background#EDE7F6;
            border-radius4px;
            z-index8;
            margin-left: -2px;
            box-shadowrgba(0000.190px 10px 20pxrgba(0000.230px 6px 6px;

        }

        .material-design .second-hand {
            width2px;
            height110px;
            background#f44336;
            z-index9;
            box-shadowrgba(0000.190px 10px 20pxrgba(0000.230px 6px 6px;

        }

        .neumorphism {
            border-radius30px;
            background#e8eaf6;
            box-shadow10px 10px 20px #d1d1d1, -10px -10px 20px #ffffff;
        }

        .neumorphism .clock-face {
            border-radius50%;
            backgroundlinear-gradient(145deg, #d1d3dd, #f8faff);
            box-shadow20px 20px 60px #c5c7d1,
                -20px -20px 60px #ffffff;
        }

        .neumorphism .clock-face-inner {
            width62%;
            height62%;
            border-radius50%;
            z-index1;
            background#e8eaf6;
            box-shadow20px 20px 40px #b0b2bb,
                -20px -20px 40px #ffffff;
        }

        .neumorphism .clock-center {
            position: absolute;
            width15px;
            height15px;
            border-radius50%;
            top132.5px;
            left132.5px;
            backgroundlinear-gradient(145deg, #f8faff, #d1d3dd);
            box-shadow1px 1px 2px #797a80,
                -1px -1px 2px #ffffff;

            z-index10;
        }

        .neumorphism .hour-mark {
            width2px;
            height24px;
        }

        .neumorphism .hour-mark::after {
            content'';
            display: block;
            position: absolute;
            bottom0;
            width2px;
            height16px;
            border-radius10px;
            background#e8eaf6;
            box-shadow: inset 1px 1px 7px #bec0ca,
                inset -1px -1px 7px #ffffff;
        }

        .neumorphism .minute-mark {
            display: none
        }

        .neumorphism .hour-number {
            display: none
        }

        .neumorphism .hour-hand {
            width6px;
            height70px;
            background#030943;
            border-radius3px;
            z-index7;
            margin-left: -2px;
        }

        .neumorphism .minute-hand {
            width4px;
            height95px;
            background#536089;
            border-radius2px;
            z-index8;
            margin-left: -1px;
        }

        .neumorphism .second-hand {
            width2px;
            height110px;
            background#dd0f2e;
            border-radius1px;
            z-index9;
        }

        .glassmorphism {
            backgroundlinear-gradient(45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab);
            background-size400% 400%;
            animation: gradientBG 15s ease infinite;
            overflow: hidden
        }

        @keyframes gradientBG {
            0% {
                background-position0% 50%;
            }

            50% {
                background-position100% 50%;
            }

            100% {
                background-position0% 50%;
            }
        }

        .glassmorphism .clock-face {
            backdrop-filterblur(8pxsaturate(150%);
            -webkit-backdrop-filterblur(16pxsaturate(180%);
            background-colorrgba(2552552550.33);
            border1px solid rgba(2092132190.6);
            overflow: hidden
        }

        .glassmorphism .clock-face::after {
            background-colorrgba(255255255, .05);
            bottom0;
            content'';
            filterblur(4px);
            left: -99px;
            position: absolute;
            right: .865%;
            top: -300px;
            transformrotate(45deg);
            z-index1;
        }

        .glassmorphism .clock-center {
            position: absolute;
            width12px;
            height12px;
            background: white;
            border-radius50%;
            top134px;
            left134px;
            z-index10;
            border10 solid rgba(0000.5)
        }

        .glassmorphism .hour-mark {
            width4px;
            height18px;
            margin-left: -1px;
        }

        .glassmorphism .hour-mark::after {
            content'';
            display: block;
            position: absolute;
            bottom0;
            width4px;
            height4px;
            border-radius50%;
            background#fff;
        }

        .glassmorphism .minute-mark {
            width1px;
            height16px;
            margin-left: -0.5px;
            border-radius50%;
        }

        .glassmorphism .minute-mark::after {
            content'';
            display: block;
            position: absolute;
            bottom0;
            width1px;
            height1px;
            border-radius50%;
            background#fff;
        }

        .glassmorphism .hour-number {
            font-size20px;
            font-weight400;
            color: white;
            width40px;
            height40px;
            line-height40px;
            display: none
        }

        .glassmorphism .hour-hand {
            width5px;
            height70px;
            backgroundrgba(2552552550.9);
            border-radius2.5px;
            z-index7;
            margin-left: -2px;
        }

        .glassmorphism .minute-hand {
            width3px;
            height95px;
            backgroundrgba(2552552550.8);
            border-radius1.5px;
            z-index8;
            margin-left: -1px;
        }

        .glassmorphism .second-hand {
            width2px;
            height110px;
            backgroundrgba(2552552551);
            z-index9;
        }

        .glassmorphism .shapes-container {
            position: absolute;
            top0;
            left0;
            width100%;
            height100%;
            overflow: hidden;
            z-index0;
            pointer-events: none;
        }

        .glassmorphism .shapes-container::after {
            background-colorrgba(255255255, .05);
            bottom0;
            content'';
            filterblur(4px);
            left: -99px;
            position: absolute;
            right: .865%;
            top: -480px;
            transformrotate(45deg);
            z-index1;
        }

        .glassmorphism .shape {
            position: absolute;
            opacity0.6;
            animation: float 20s infinite ease-in-out;
        }

        .glassmorphism .shape.circle {
            width120px;
            height120px;
            backdrop-filterblur(5pxsaturate(150%);
            -webkit-backdrop-filterblur(16pxsaturate(180%);
            background-colorrgba(2552552550.38);
            border1px solid rgba(2092132190.8);
            border-radius50%;
            top20%;
            left10%;
            animation-duration10s;
        }

        .glassmorphism .shape.rounded-square {
            width100px;
            height100px;
            backdrop-filterblur(5pxsaturate(150%);
            -webkit-backdrop-filterblur(16pxsaturate(180%);
            background-colorrgba(2552552550.38);
            border1px solid rgba(2092132190.8);
            border-radius25px;
            top70%;
            left60%;
            animation-duration16s;
        }

        @keyframes float {
            0% {
                transformtranslateY(0pxtranslateX(0pxrotate(0deg);
            }

            50% {
                transformtranslateY(-25pxtranslateX(15pxrotate(180deg);
            }

            100% {
                transformtranslateY(0pxtranslateX(0pxrotate(360deg);
            }
        }

        .claymorphism {
            border-radius30px;
            background#f4f4fc;
            box-shadow35px 35px 68px 0px rgba(1451922550.5), inset -2px -2px 16px 0px rgba(1451922550.6), inset 0px 11px 28px 0px rgb(255255255);
        }

        .claymorphism .clock-face {
            background#f4f4fc;
            border-radius50%;
            box-shadow35px 35px 68px 0px rgba(1451922550.5), inset -7px -7px 16px 0px rgba(1451922550.6), inset 0px 11px 28px 0px rgb(255255255);
        }

        .claymorphism .clock-center {
            position: absolute;
            width18px;
            height18px;
            background#6457f9;
            border-radius50%;
            top131px;
            left131px;
            box-shadow3px 3px 6px rgba(1010400.2);
            z-index10;
        }

        .claymorphism .hour-mark {
            width4px;
            height12px;
            background#9c92ff;
            margin-left: -2px;
            border-radius2px;
        }

        .claymorphism .minute-mark {
            width2px;
            height6px;
            background#c4beff;
            margin-left: -1px;
            border-radius1px;
        }

        .claymorphism .hour-number {
            font-size22px;
            font-weight600;
            color#6457f9;
            width40px;
            height40px;
            line-height40px;
        }

        .claymorphism .hour-hand {
            width8px;
            height70px;
            background#6457f9;
            border-radius4px;
            z-index7;
            margin-left: -3px;
        }

        .claymorphism .minute-hand {
            width6px;
            height95px;
            background#9c92ff;
            border-radius3px;
            z-index8;
            margin-left: -2px;
        }

        .claymorphism .second-hand {
            width3px;
            height110px;
            background#ff6b6b;
            border-radius1.5px;
            z-index9;
        }

        .brutalism {
            background#fff;
        }

        .brutalism {
            border-radius0;
            background#c0f7fe;
            box-shadow: none;
            border4px solid #000;
            transition: all 0.1s;
            /* padding: 25px; */
        }

        .brutalism .clock-face {
            background#91a8ee;
            border2px solid black;
            box-shadow: -16px 0px 0px #000;
        }

        .brutalism .clock-face-inner {
            display: flex;
            align-items: center;
            justify-content: center;
            width90%;
            height90%;
            border2px solid black;
            border-radius50%;
            z-index1;
            background#fe90e8;
            box-shadow: -8px 0px 0px #000 inset;
        }

        .brutalism .clock-face-inner-2 {
            width62%;
            height62%;
            border-radius50%;
            z-index2;
            background#ffff19;
            box-shadow: -4px 0px 0px #000 inset;
        }

        .brutalism .clock-center {
            position: absolute;
            width16px;
            height16px;
            background#000;
            border-radius50%;
            top132px;
            left132px;
            z-index10;
        }

        .brutalism .hour-mark {
            width1px;
            height50px;
            margin-left: -5px;
            z-index12
        }

        .brutalism .hour-mark::after {
            content'';
            display: block;
            position: absolute;
            bottom0;
            width1px;
            height24px;
            border-radius50%;
            background#000;
        }

        .brutalism .minute-mark {
            display: none
        }

        .brutalism .hour-hand {
            width8px;
            height40px;
            background#000;
            z-index7;
            border-radius5px;
            margin-left: -4px
        }

        .brutalism .minute-hand {
            width8px;
            height64px;
            background#000;
            z-index8;
            border-radius5px;
            margin-left: -4px
        }

        .brutalism .second-hand {
            display: none
        }

        .brutalism .hour-number {
            display: none
        }

        .minimalism .card {
            border-radius18px;
            background#ffffff;
            box-shadow0 5px 20px rgba(0000.05);
            padding40px;
        }

        .minimalism .clock-face {
            background#ffffff;
            box-shadow0 5px 20px rgba(0000.05);
        }

        .minimalism .clock-center {
            position: absolute;
            width8px;
            height8px;
            background#111;
            border-radius50%;
            top136px;
            left136px;
            z-index10;
        }

        .minimalism .hour-mark {
            width1px;
            height8px;
            background#111;
            margin-left: -0.5px;
            opacity0.2;
        }

        .minimalism .minute-mark {
            width1px;
            height4px;
            background#111;
            margin-left: -0.5px;
            opacity0.1;
        }

        .minimalism .hour-number {
            font-family"SF Pro Display", -apple-system, BlinkMacSystemFont, sans-serif;
            font-size18px;
            font-weight300;
            color#111;
            width40px;
            height40px;
            line-height40px;
            opacity0.5;
        }

        .minimalism .hour-number:nth-child(3n) {
            opacity1;
        }

        .minimalism .hour-hand {
            width3px;
            height65px;
            background#111;
            border-radius1.5px;
            z-index7;
        }

        .minimalism .minute-hand {
            width2px;
            height90px;
            background#111;
            border-radius1px;
            z-index8;
        }

        .minimalism .second-hand {
            width1px;
            height110px;
            background#ff3b30;
            z-index9;
        }

        @media (min-width: 699pxand (max-width: 705px) {
            .card {
                transformscale(0.45);
                margin: -140px -120px
            }

            h1 {
                font-size1.25em
            }
        }
    style>
head>

body>
    h1>Museum of Clocksh1>
    div class="container">
        
        div class="skeuomorphic card"
            data-description="Inspired by real-world objects, this design uses shadows, textures, and depth to create a familiar, almost tactile interface.">
            h2>Skeuomorphismh2>
            div class="clock-container">
                div class="clock-bezel">div>
                div class="clock-face">div>
                div class="clock-reflection">div>
                div class="hour-marks" id="skeuomorphic-hour-marks">div>
                div class="hour-hand hand" id="skeuomorphic-hour-hand">div>
                div class="minute-hand hand" id="skeuomorphic-minute-hand">div>
                div class="second-hand hand" id="skeuomorphic-second-hand">div>
                div class="clock-center">div>
            div>
        div>

        
        div class="flat-design card"
            data-description="Clean, crisp, and modern. Flat design removes all unnecessary details — no shadows or gradients, just bold colors and clear shapes.">
            h2>Flat Designh2>
            div class="clock-container">
                div class="outer-ring">div>
                div class="clock-face">div>
                div class="hour-marks" id="flat-design-hour-marks">div>
                div class="hour-hand hand" id="flat-design-hour-hand">div>
                div class="minute-hand hand" id="flat-design-minute-hand">div>
                div class="second-hand hand" id="flat-design-second-hand">div>
                div class="clock-center">div>
            div>
        div>

        
        div class="material-design card "
            data-description="Google’s signature style that blends depth and motion. It uses layered elements, smooth animations, and consistent shadowing for clarity and structure.">
            h2>Material Designh2>
            div class="clock-container">
                div class="clock-face-inner">

                div>
                div class="clock-face">div>
                div class="hour-marks" id="material-design-hour-marks">div>
                div class="hour-hand hand" id="material-design-hour-hand">div>
                div class="minute-hand hand" id="material-design-minute-hand">div>
                div class="second-hand hand" id="material-design-second-hand">div>
                div class="clock-center">div>
            div>
        div>

        
        div class="neumorphism card"
            data-description="A soft, subtle blend of light and shadow. Elements appear to be pressed into or extruded from the background, giving a modern, minimalist 3D look.">
            h2>Neumorphismh2>
            div class="clock-container">
                div class="clock-face-inner">div>
                div class="clock-face">div>
                div class="hour-marks" id="neumorphism-hour-marks">div>
                div class="hour-hand hand" id="neumorphism-hour-hand">div>
                div class="minute-hand hand" id="neumorphism-minute-hand">div>
                div class="second-hand hand" id="neumorphism-second-hand">div>
                div class="clock-center">div>
            div>
        div>

        
        div class="glassmorphism card "
            data-description="A frosted glass aesthetic with soft blurs, transparency, and layered depth. Sleek, futuristic, and slightly surreal.">
            div class="shapes-container">
                div class="shape circle">div>
                div class="shape rounded-square">div>
            div>
            h2>Glassmorphismh2>
            div class="clock-container">
                div class="clock-face">div>
                div class="hour-marks" id="glassmorphism-hour-marks">div>
                div class="hour-hand hand" id="glassmorphism-hour-hand">div>
                div class="minute-hand hand" id="glassmorphism-minute-hand">div>
                div class="second-hand hand" id="glassmorphism-second-hand">div>
                div class="clock-center">div>
            div>
        div>

        
        div class="claymorphism card "
            data-description="Fun and friendly with thick, rounded edges and soft shadows. Elements look like they’re made of colorful, squishy clay. Playful and approachable.">
            h2>Claymorphismh2>
            div class="clock-container">
                div class="clock-face">div>
                div class="hour-marks" id="claymorphism-hour-marks">div>
                div class="hour-hand hand" id="claymorphism-hour-hand">div>
                div class="minute-hand hand" id="claymorphism-minute-hand">div>
                div class="second-hand hand" id="claymorphism-second-hand">div>
                div class="clock-center">div>
            div>
        div>

        
        div class="brutalism card "
            data-description="Neo-brutalism is a bold, raw design style that embraces minimal styling and harsh visuals. It features flat colors, visible grids, system fonts, and an intentionally unpolished look.">
            h2>Neo-brutalismh2>
            div class="clock-container">
                div class="clock-face">div>
                div class="clock-face-inner">
                    div class="clock-face-inner-2">div>
                div>

                div class="hour-marks" id="brutalism-hour-marks">div>
                div class="hour-hand hand" id="brutalism-hour-hand">div>
                div class="minute-hand hand" id="brutalism-minute-hand">div>
                div class="second-hand hand" id="brutalism-second-hand">div>
                div class="clock-center">div>
            div>
        div>

        
        div class="minimalism card "
            data-description="Simplicity at its finest. Focuses on clean lines, open space, and functionality. Less is more, with every element carefully chosen for maximum impact.">
            h2>Minimalismh2>
            div class="clock-container">
                div class="clock-face">div>
                div class="hour-marks" id="minimalism-hour-marks">div>
                div class="hour-hand hand" id="minimalism-hour-hand">div>
                div class="minute-hand hand" id="minimalism-minute-hand">div>
                div class="second-hand hand" id="minimalism-second-hand">div>
                div class="clock-center">div>
            div>
        div>
    div>
    script>
        $(document).ready(function () {
            setupClock("skeuomorphic");
            setupClock("flat-design");
            setupClock("material-design");
            setupClock("neumorphism");
            setupClock("glassmorphism");
            setupClock("brutalism");

            function setClockHands() {
                const now = new Date();
                const hours24 = now.getHours();
                const hours = hours24 % 12 || 12;
                const minutes = now.getMinutes();
                const seconds = now.getSeconds();
                const ampm = hours24 >= 12 ? "PM" : "AM";

                const hourDegrees = (hours % 12) * 30 + minutes * 0.5;
                const minuteDegrees = minutes * 6 + seconds * 0.1;
                const secondDegrees = seconds * 6;

                $("[id$='-hour-hand']").css("transform"`rotate(${hourDegrees}deg)`);

                $("[id$='-minute-hand']").css("transform"`rotate(${minuteDegrees}deg)`);

                $("[id$='-second-hand']").css("transform"`rotate(${secondDegrees}deg)`);
            }

            function setupClock(style{
                for (let i = 0; i 12; i++) {
                    const hourMark = $("

“).addClass(“hour-mark”);
hourMark.css(“transform”`rotate(${i * 30}deg)`);
$(`#${style}-hour-marks`).append(hourMark);

const hourNumber = $(

“)
.addClass(“hour-number”)
.text(i === 0 ? 12 : i);
const angle = i * 30;
const radius = 112;
const x = 150 + radius * Math.sin((angle * Math.PI) / 180);
const y = 150 – radius * Math.cos((angle * Math.PI) / 180);

hourNumber.css({
left: x – 30,
top: y – 30
});

$(`.${style} .clock-face`).append(hourNumber);

for (let j = 1; j 4; j++) {
if (j 5) {
const minuteMark = $(

“).addClass(“minute-mark”);
minuteMark.css(“transform”`rotate(${i * 30 + j * 6}deg)`);
$(`#${style}-hour-marks`).append(minuteMark);
}
}
}
}

setClockHands();
setInterval(setClockHands, 1000);
});

script>
body>

html>

HTML 结构

 

    • h1:显示页面标题“Museum of Clocks”。

 

    • container:包含多个时钟展示卡片。

 

    • 每个卡片如 skeuomorphic、flat-design、material-design 等都包含一个时钟容器,用于展示不同设计风格的时钟。

 

    • 每个时钟容器包含时钟的指针、刻度、数字等元素。

 

 

CSS 样式

 

全局样式

 

    • body:设置页面的背景颜色、最小高度、外边距和内边距。

 

    • h1:设置标题的字体大小、颜色、对齐方式等。

 

    • .container:定义容器的布局,使用 Flexbox 实现响应式布局。

 

 

卡片样式

 

    • .card:定义卡片的基本样式,包括背景颜色、圆角、阴影、大小等。

 

    • .card:hover::after:定义卡片悬停时的提示信息样式。

 

 

时钟样式

 

    • .clock-container:定义时钟容器的样式,包括大小、位置等。

 

    • .clock-face:定义时钟表盘的样式,包括背景颜色、圆角等。

 

    • .hour-marks、.minute-marks:定义时钟的刻度样式。

 

    • .hour-hand、.minute-hand、.second-hand:定义时钟指针的样式,包括宽度、高度、颜色、旋转原点等。

 

    • .clock-center:定义时钟中心点的样式。

 

 

不同设计风格

 

  • 每种设计风格(如 skeuomorphic、flat-design、material-design 等)都有对应的 CSS 类,定义了不同的颜色、阴影、渐变等样式,以实现不同的视觉效果。

 

JavaScript 功能说明

 

时钟初始化

 

使用 setupClock 函数为每种设计风格的时钟初始化刻度和指针。 使用 setClockHands 函数更新时钟指针的位置,实现动态时钟效果。

 

动画效果

 

使用 setInterval 函数每秒更新一次时钟指针的位置,实现时钟的动态运行。

 


 

各位互联网搭子,要是这篇文章成功引起了你的注意,别犹豫,关注、点赞、评论、分享走一波,让我们把这份默契延续下去,一起在知识的海洋里乘风破浪!