• 打地鼠小游戏


    html:

     

    0分


       

           
           

               


                   
                   
                   
                   
               
               
                   
                   
                   
                   
               
               
                   
                   
                   
                   
               
               
                   
                   
                   
                   
               
           

                       
                   

           

               

    开始


               

    重新开始


                    
           

       

    css:

    * {
                margin: 0;
                padding: 0;
            }

            .cleanfix {
                content: "";
                clear: both;
                display: block;
            }

            .box {
                width: 1180px;
                margin: 0 auto;
            }

            .box .txt {
                display: block;
                text-align: center;
                width: 1180px;
                height: 50px;
            }

            .box .txt p {
                width: 200px;
                height: 40px;
                display: inline-block;
                font-size: 30px;
                line-height: 20px;
                text-align: center;
                font-weight: bold;
                margin: 5px 5px;
                background-color: azure;
            }
            .fen{
                margin-top: 10px;
                font-size: 50px;
                line-height: 50px;
                text-align: center;
            }

            table {

                background: url(bg.jpg) no-repeat;
                background-size: 100% 100%;
                width: 800px;
                height: 600px;
                border: 1px solid red;
                margin: 20px auto;
                border-collapse: collapse;
            }

            a{
                text-decoration: none;
                color: black;
            }

            td {
                position: relative;
                width: 200px;
                height: 100px;
                background: url(hole.png) no-repeat center bottom;
                background-size: 200px;
                overflow: hidden;
            }

            td img {
                /* position: absolute; */
                width: 100px;
                height: 100px;
                position: absolute;
                left: 0;
                top: 0px;
                z-index: 2;
            }

            .dong {
                position: absolute;

                bottom: 20px;
                left: 50px;
                width: 100px;
                height: 100px;
                overflow: hidden;
            }

            .txt p {
                cursor: pointer;
                
            }
            .dds{
                animation-name: chulai;
                animation-duration: .6s;
            }
            @keyframes chulai{
                0%{
                    top: 80px;
                }
                100%{
                    top: 0;
                }
            }

    js:

    var td = document.querySelectorAll('td')
        var star = document.querySelector(".start")
        var again = document.querySelector(".again")
        var fen=document.querySelector(".fen")
        var timer = null
        var f=0

        star.addEventListener('click', function () {
            var td = document.querySelectorAll('td')
            var table = document.querySelector('table')
            var cursor = document.querySelector(".cursor")

            function ss() {
                var suiji = Math.floor(Math.random() * 16)
                td[suiji].innerHTML = `
                   


                       
                   
     
                    `
                    console.log(td[suiji].children);   
            }
            ss()
           
            table.addEventListener("mousemove", function () {
                table.style.cursor = 'url(cursor.png),auto'
            })
            td.forEach(function (v, i) {
                td[i].addEventListener('mousedown', function (e) {
                    table.style.cursor = 'url(cursor-down.png),auto'
                    if (e.target.tagName == 'IMG') {
                        td[i].textContent = ''
                        ss()
                        fen.textContent=`${f+=10}分`
                        // console.log(td[i]);
                    }
                   
                })
                td[i].addEventListener('mouseup', function () {
                    table.style.cursor = 'url(cursor.png),auto'
                })
            })
            
            clearInterval(timer)
            timer = setInterval(function () {
                ss()
            }, 1366)
        })

     

  • 相关阅读:
    代码随想录第五十五天打卡
    第四章 特定功能单元 第八节 其他不重要内容 (SpringMVC)
    计算机毕业设计之java+ssm基于web的校园短期闲置资源置换平台
    超详细springcloud sentinel教程~
    有些东西你要是早点懂,也不至于走那么多冤枉路
    Openresty人机验证流程
    联想笔记本电脑触摸板失灵了怎么办
    针对springcloud gateway 跨域问题解决方案
    YOLOv7独家原创改进:最新原创WIoU_NMS改进点,改进有效可以直接当做自己的原创改进点来写,提升网络模型性能精度
    Redis存取架构及命令详解
  • 原文地址:https://blog.csdn.net/weixin_55711841/article/details/126073728