网页显示时间

案例非本人创作

最近在找vue3的视频 找到b站知乎日报 讲了vue3 setup API 

然后有项目可是我中间一直卡了proxy跨域问题 一直获取不到数据

弄了两天没有人带都是自学 所以我就放弃这个项目,做一下有趣的东西转换一下心情

【html+css+js】网页显示时间【html+css+js】网页显示时间_哔哩哔哩_bilibili【html+css+js】网页显示时间

运行成功

报错的话

1 second seconds注意有没有写错

2 JS部分里的temps temph注意有没有写错

 

<!DOCTYPE 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">
    <title>Document</title>
    <link rel="stylesheet" href="213.css">
<body>
    <div class="relative">
        <div class="padding">
            <div id="time-hour" class="text">00</div>
            <div class="time-temp">:</div>
            <div id="time-minutes" class="text">00</div>
            <div class="time-temp">:</div>
            <div id="time-second" class="text">00</div>
        </div>
        <div class="padding-bottom">
            <div id="time-year" class="text">00</div>
            <div class="time-ltemp">-</div>
            <div id="time-month" class="text">00</div>
            <div class="time-ltemp">-</div>
            <div id="time-day" class="text">00</div>
        </div>
    </div>
    <script>
        function time(){
            var time= new Date();
            var hour;
            var minutes;
            var seconds;
            var year;
            var month;
            var day;
            year = time.getFullYear();
            month = time.getMonth();
            day = time.getDate();
            document.getElementById("time-year").innerHTML=year;
            document.getElementById("time-month").innerHTML=month + 1;
            document.getElementById("time-day").innerHTML=day;
            var temph=time.getHours();
            if(temph <=12 && temph >0){
                hour = "0" + temph;
            }else{
                hour=temph;
            }
            var tempm = time.getMinutes();
            if(tempm <10 && tempm >=0){
                minutes = "0" + tempm;
            }else{
                minutes = tempm;
            }
            var temps = time.getSeconds();
            if(temps < 10 && temps >=0){
                seconds = "0" + temps;
            }else{
                seconds = temps;
            }
            document.getElementById("time-hour").innerHTML=hour;
            document.getElementById("time-minutes").innerHTML=minutes;
            document.getElementById("time-second").innerHTML=seconds;
        }
        window.setInterval("time()",100);
    </script>
</body>
</html>
*{
    padding: 0;
    margin: 0;
    box-sizing: border-box;
    font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif';
}
div{
    display: flex;
}
body{
    width: 100%;
    height: 100%;
    overflow: hidden;
}
.relative{
    min-width: 1464px;
    min-height: 864px;
    padding: 6.5rem 0 0 !important;
    margin-right: auto !important;
    margin-left: auto !important;
    background: #040d21;
    position: relative;
    display: block;
}
.padding{
    position: absolute;
    top: 30%;
    left: 31%;
    color: #fff;
    font-size: 118px;
    font-weight: 800;
}
.padding-bottom{
    position: absolute;
    top: 45%;
    left: 43%;
    color: #fff;
    font-size: 36px;
    font-weight: 500;
}
.time-temp{
    margin: 0 20px;
    transform: translateY(-20px);
}
.time-ltemp{
    margin: 0 10px;
    transform: translateY(-5px);
}
.text{
    background: linear-gradient(-210deg,#a2facf 0%,#64acff 100%);
    color: transparent;
    -webkit-background-clip: text;
    letter-spacing: -0.03em;
    display: block;
    align-items: center;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值