一个好玩的辞职信HTML版

举报
海拥 发表于 2021/11/26 21:16:37 2021/11/26
【摘要】 🌊 作者主页:海拥🌊 简介:🏆CSDN全栈领域优质创作者、🥇HDZ核心组成员、🥈蝉联C站周榜前十🌊 粉丝福利:粉丝群 每周送六本书,不定期送各种小礼品话不多说,直接上代码<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>辞职信</title> <style> ht...

🌊 作者主页:海拥
🌊 简介:🏆CSDN全栈领域优质创作者、🥇HDZ核心组成员、🥈蝉联C站周榜前十
🌊 粉丝福利:粉丝群 每周送六本书,不定期送各种小礼品

话不多说,直接上代码

<!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="./cizhi.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>

点开是这样的
在这里插入图片描述
当你想点不同意时他就会自动爬开
在这里插入图片描述

除非你点了同意
在这里插入图片描述

【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

举报
请填写举报理由
0/200