js-倒计时

<!DOCTYPE html>
<html lang="en">
<script src="jquery-1.8.2.min.js"></script>
<script src="jq.snow.js"></script>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        .cutdowntime {
            width: 578px;
            margin: 300px auto 0;
        }
        
        .cutdowntime strong {
            display: block;
            font-size: 30px;
            color: #fff;
            margin-bottom: 20px;
        }
        
        .cutdowntime span {
            display: inline-block;
            margin: 0 0 0 3px;
            width: 100px;
            height: 100px;
            text-align: center;
            line-height: 100px;
            background-color: #000;
            font-size: 40px;
            color: #fff;
        }
        
        .cutdowntime span:nth-child(2n+1) {
            width: 30px;
            text-align: center;
            font-size: 20px;
            background: none;
            vertical-align: top;
        }
    </style>
</head>

<body style="background-color:crimson;  overflow: hidden;">
    <div class="cutdowntime">
        <strong>距离2020年春节还有:</strong>
        <span class="dates">00</span>
        <span>天</span>
        <span class="hour">00</span>
        <span>时</span>
        <span class="minute">00</span>
        <span>分</span>
        <span class="second">00</span>
        <span>秒</span>
    </div>
    <script>
        //1、获取元素
        window.addEventListener('load', function() {
            var bodyHeight = document.documentElement.clientHeight;
            // console.log(bodyHeight);

            document.body.style.height = bodyHeight + 'px'
        })
        var dates = document.querySelector('.dates');
        var hour = document.querySelector('.hour');
        var minute = document.querySelector('.minute');
        var second = document.querySelector('.second');
        var iptTime = +new Date('2020-01-24 00:00:00');
        countDown();
        setInterval(countDown, 1000);
        $(function() {
            $.fn.snow({
                minSize: 5, //雪花的最小尺寸
                maxSize: 40, //雪花的最大尺寸
                newOn: 100 //雪花出现的频率 这个数值越小雪花越多
            });
        });

        function countDown() {
            var nowsTime = +new Date();
            var time = (iptTime - nowsTime) / 1000; //剩余时间总的描述
            var d = parseInt(time / 60 / 60 / 24); //天
            var d = d < 10 ? '0' + d : d;
            dates.innerHTML = d;
            var h = parseInt(time / 60 / 60 % 24); //时
            var h = h < 10 ? '0' + h : h;
            hour.innerHTML = h;
            var m = parseInt(time / 60 % 60); //分
            var m = m < 10 ? '0' + m : m;
            minute.innerHTML = m;
            var s = parseInt(time % 60); //秒
            var s = s < 10 ? '0' + s : s;
            second.innerHTML = s;
            //return '距离' + times + ' 还有' + d + '天' + h + '时' + m + '分' + s + '秒';
        }
        //console.log(countDown('2020-01-24 00:00:00'));
    </script>
</body>

</html>

在这里插入图片描述
雪花效果:https://blog.csdn.net/ghjzzhg/article/details/86088481

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值