html--动态时钟


<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>时钟</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
    <script src="js/test.js"></script>
    <script src="js/common.js"></script>
    <script src="js/config.js"></script>
</head>

<style>

    *{
        margin: 0;
        padding: 0;
    }

    body{
        /* background: url("../images/bg.jpg") no-repeat;
        background-size: 100% 100%; */
        background-attachment: fixed;
        color: red;
        font-size: 12px;
        font-weight: bold;
        overflow: hidden;
        width: 1000px;
        height: 900px;
        font-family: "微软雅黑";

    }

    audio{
        position: absolute;
        right: 0;
        opacity: 0.1;
        transition: all 1s;

    }

    audio:hover{
        opacity: 1;
    }

    .current{
        color: #D1A3F7;
    }


    video{
        z-index: -1;
        /* object-fit: fill; */
        position: fixed;
        /* right: 0px;
        bottom: 0px; */
        min-width: 100%;
        min-height: 100%;
        /* height: auto;
        width: auto; */
    }


    .main-content{
        position: absolute;
        top:50%;
        left: 50%;
    }


    .main-content .year{
        position: relative;
        top: -13px;
        left: -38px;
        text-align: center
    }

    .main-content .year span{
        position: absolute;
        width: 80px;
    }



    .main-content .month{
        position: relative;
        top: -13px;
        left: 40px;
    }

    .month span{
        position: absolute;
        width: 60px;

    }




    .main-content .day{
        position: relative;
        top: -13px;
        left: 85px;
    }

    .day span{
        position: absolute;
        width: 65px;

    }




    .main-content .week{
        position: relative;
        top: -13px;
        left: 145px;
    }
    .week span{
        position: absolute;
        width: 65px;

    }


    .main-content .shichen{
        position: relative;
        top: -13px;
        left: 200px;
    }
    .shichen span{
        position: absolute;
        width: 125px;

    }


    .main-content .hour{
        position: relative;
        top: -13px;
        left: 240px;
    }
    .hour span{
        position: absolute;
        width: 60px;

    }


    .main-content .minute{
        position: relative;
        top: -13px;
        left: 300px;
    }
    .minute span{
        position: absolute;
        width: 60px;

    }


    .main-content .second{
        position: relative;
        top: -13px;
        left: 370px;
    }
    .second span{
        position: absolute;
        width: 60px;

    }



</style>



<body>



    <div class="main-content">
        <div class="year">
            <!-- <span>2019</span> -->
        </div>
        <div class="month"></div>
        <div class="day"></div>
        <div class="week"></div>
        <div class="shichen"></div>
        <div class="hour"></div>
        <div class="minute"></div>
        <div class="second"></div>
    </div>



</body>
</html>

在这里插入图片描述

在这里插入图片描述

  • 21
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
HTML5网页动态时钟源码可以使用JavaScript和CSS来实现。下面是一个简单的示例: HTML代码: ```html <!DOCTYPE html> <html> <head> <title>动态时钟</title> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <div class="clock"> <div id="hour" class="hand"></div> <div id="minute" class="hand"></div> <div id="second" class="hand"></div> </div> <script src="script.js"></script> </body> </html> ``` CSS代码(style.css): ```css .clock { width: 200px; height: 200px; background-color: #f1f1f1; border-radius: 50%; position: relative; margin: 0 auto; margin-top: 100px; overflow: hidden; } .hand { background-color: #333; position: absolute; left: 50%; bottom: 50%; transform-origin: bottom center; } #hour { width: 8px; height: 60px; margin-left: -4px; } #minute { width: 4px; height: 80px; margin-left: -2px; } #second { width: 2px; height: 100px; margin-left: -1px; } ``` JavaScript代码(script.js): ```javascript function rotateClockHands() { var now = new Date(); var hourAngle = now.getHours() % 12 * 30 + now.getMinutes() / 2; var minuteAngle = now.getMinutes() * 6; var secondAngle = now.getSeconds() * 6; document.getElementById('hour').style.transform = 'rotate(' + hourAngle + 'deg)'; document.getElementById('minute').style.transform = 'rotate(' + minuteAngle + 'deg)'; document.getElementById('second').style.transform = 'rotate(' + secondAngle + 'deg)'; } setInterval(rotateClockHands, 1000); ``` 这段代码创建一个200x200像素的圆形时钟,并用JavaScript动态旋转时、分、秒指针。CSS用于设置时钟的样式,JavaScript负责计算当前时间并将指针旋转到正确的位置。setInterval()函数用于每秒钟更新一次指针的旋转角度,使时钟指针动起来。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

fo安方

觉得俺的文章还行,感谢打赏,爱

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值