• 💂 个人网站:【 海拥】【五子棋】【象棋】
  • 🤟 风趣幽默的前端学习课程:👉28个案例趣学前端
  • 💅 想寻找共同学习交流、摸鱼划水的小伙伴,请点击【摸鱼交流群】
  • 💬 免费且实用的计算机相关知识题库:👉进来逛逛

给大家安利一个免费且实用的前端刷题(面经大全)网站,👉点击跳转到网站。

在线演示:https://haiyong.site/moyu/cizhi.html

话不多说,直接上代码

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>辞职信</title>
    <style>
        html, body {
            margin: 0;
            padding: 0;
            background: #f2f1f6;
        }
        .container {
            position: relative;
            width: 500px;
            height: 300px;
            background: #f2f1f6;

        }
        .container h1 {
            margin-top: 0;
            text-align: center;
        }
        .container img {
            vertical-align: -70px;
        }
        .bd {
            padding-left: 30px;
        }
        .ft {
            position: absolute;
            width: 100%;
            bottom: 20px;
            padding: 0 30px;
            line-height: 30px;
            box-sizing: border-box;
        }
        .btn-group {
            float: left;
        }
        .fr {
            float: right;
        }
        button {
            cursor: pointer;
        }
        #p1 {
        }
        .not-allow {
            position: relative;
        }
        #p2 {
            display: none;
        }
        .red {
            margin: 0;
            font-size: 24px;
            padding: 30px 40px;
            color: red;
            letter-spacing: 4px;
        }
        .wavy {
            text-decoration: underline;
            text-decoration-style: wavy;
        }
        .name {
            padding-left: 10px;
        }
        .btn {
            padding: 6px 12px;
        }
    </style>
</head>
<body>
    <div class="container">
        <div id="p1">
            <h1>辞职信</h1>
            <div class="bd">
                尊敬的各位领导: <img src="https://img-blog.csdnimg/7722fb0cb01147168f2ed57459f18b47.png" width="120"/>
            </div>

            <div class="ft">
                <div class="btn-group">
                    <button class="btn allow">同意</button>
                    <button class="btn not-allow" id="not-allow">不同意</button>
                </div>
                <div class="fr">
                    辞职人: <span class="name">小海</span>
                </div>
            </div>
        </div>
        <div id="p2">
            <h2 class="red">
                老板大人, 臣告退了, 这一退可能</span>就是一辈子了。<br/>
                !!!!敬礼!!!!
            </h2>
            <div class="ft">
                <button class="btn fr exit">退出</button>
            </div>
        </div>
    </div>
    <script>
        (function(){
            function $(selector) {
                return document.querySelector(selector);
            }
            var $p1 = document.getElementById('p1');
            var $p2 = document.getElementById('p2');
            var $container = $('.container');
            var $btn = $('#not-allow');
            var isBlockClose = true;

            var maxX = $container.clientWidth - 1, maxY = $container.clientHeight - 1;
            var originPos = $btn.getBoundingClientRect();

            $('.allow').addEventListener('click', function() {
                $p1.style.display = 'none';
                $p2.style.display = 'block';
            });
            $btn.addEventListener('mouseover', function() {
                this.style.left = Math.floor(Math.random() * maxX - originPos.left) + 'px';
                this.style.top = Math.floor(Math.random() * maxY - originPos.top) + 'px';
                //console.log(this.style.left, this.style.top);
            });
            $('.exit').addEventListener('click', function() {
                isBlockClose = false;
                window.close();
            });
            window.addEventListener('beforeunload', function(e) {
                if (isBlockClose) {
                    alert("此路不通");
                    e.returnValue = false;
                    e.preventDefault();
                    return "此路不通";
                }
            });
        })();
    </script>
</body>
</html>

图片素材:

点开是这样的

当你想点不同意时他就会自动爬开

除非你点了同意

关注我,粉丝即可免费下载:https://download.csdn/download/qq_44273429/13457629

更多好玩:https://haiyong.site/moyu/

更多推荐

一个好玩的辞职信HTML版