跳到正文

个人记录

blog及其他存档

Mmap约 35 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2025年12月12日
篇幅
约 35 分钟

版本

  1. v1当前

JS

JavaScript
const searchInput = document.getElementById('search-input');
        const posts = document.querySelectorAll('.post');
        const categoryFilter = document.getElementById('category-filter');

        searchInput.addEventListener('input', function () {
            const searchTerm = this.value.toLowerCase();
            posts.forEach(post => {
                const title = post.querySelector('h2').textContent.toLowerCase();
                if (title.includes(searchTerm)) {
                    post.style.display = 'block';
                } else {
                    post.style.display = 'none';
                }
            });
        });

        categoryFilter.addEventListener('change', function () {
            const selectedCategory = this.value;
            posts.forEach(post => {
                const postCategory = post.getAttribute('data-category');
                if (selectedCategory === 'all' || postCategory === selectedCategory) {
                    post.style.display = 'block';
                } else {
                    post.style.display = 'none';
                }
            });
        });

        const aboutLink = document.getElementById('about-link');
        const aboutModal = document.getElementById('about-modal');
        const aboutClose = aboutModal.querySelector('.close');

        aboutLink.addEventListener('click', function (e) {
            e.preventDefault();
            aboutModal.style.display = 'block';
        });

        aboutClose.addEventListener('click', function () {
            aboutModal.style.display = 'none';
        });

        window.addEventListener('click', function (e) {
            if (e.target === aboutModal) {
                aboutModal.style.display = 'none';
            }
        });

        const contactLink = document.getElementById('contact-link');
        const contactModal = document.getElementById('contact-modal');
        const contactClose = contactModal.querySelector('.close');
        const contactL = document.getElementById('contact');
        const contactM = document.getElementById('contact-modal');
        const contactC = contactModal.querySelector('.close');

        contactLink.addEventListener('click', function (e) {
            e.preventDefault();
            contactModal.style.display = 'block';
        });

        contactClose.addEventListener('click', function () {
            contactModal.style.display = 'none';
        });

        window.addEventListener('click', function (e) {
            if (e.target === contactM) {
                contactM.style.display = 'none';
            }
        });

        contactL.addEventListener('click', function (e) {
            e.preventDefault();
            contactM.style.display = 'block';
        });

        contactC.addEventListener('click', function () {
            contactM.style.display = 'none';
        });

        window.addEventListener('click', function (e) {
            if (e.target === contactM) {
                contactM.style.display = 'none';
            }
        });




        // 通知功能
        const notificationsLink = document.getElementById('notifications-link');
        const notificationsModal = document.getElementById('notifications-modal');
        const notificationsClose = notificationsModal.querySelector('.close');

        notificationsLink.addEventListener('click', function (e) {
            e.preventDefault();
            notificationsModal.style.display = 'block';
        });

        notificationsClose.addEventListener('click', function () {
            notificationsModal.style.display = 'none';
        });

        window.addEventListener('click', function (e) {
            if (e.target === notificationsModal) {
                notificationsModal.style.display = 'none';
            }
        });

    (function () {
    var a_idx = 0;
    window.onclick = function (event) {
        var a = new Array("❤我不去想是否能够成功❤","❤既然选择了远方❤","❤便只顾风雨兼程❤","❤我不去想能否赢得爱情❤","❤既然钟情于玫瑰❤","❤就勇敢地吐露真诚❤","❤我不去想身后会不会袭来寒风冷雨❤","❤既然目标是地平线❤","❤留给世界的只能是背影❤","❤我不去想未来是平坦还是泥泞❤","❤只要热爱生命❤","❤一切,都在意料之中❤");
        var heart = document.createElement("b"); //创建b元素
        heart.onselectstart = new Function('event.returnValue=false'); //防止拖动
        document.body.appendChild(heart).innerHTML = a[a_idx]; //将b元素添加到页面上
        a_idx = (a_idx + 1) % a.length;
        heart.style.cssText = "position: fixed;left:-100%;"; //给p元素设置样式
        var f = 8, // 字体大小
            x = event.clientX - f / 2, // 横坐标
            y = event.clientY - f, // 纵坐标
            c = randomColor(), // 随机颜色
            a = 1, // 透明度
            s = 0.9; // 放大缩小
        var timer = setInterval(function () { //添加定时器
            if (a <= 0) {
                document.body.removeChild(heart);
                clearInterval(timer);
            } else {
                heart.style.cssText = "font-size:16px;cursor: default;position: fixed;color:" +
                    c + ";left:" + x + "px;top:" + y + "px;opacity:" + a + ";transform:scale(" +
                    s + ");";
                y--;
                a -= 0.016;
                s += 0.002;
            }
        }, 15)
    }
    // 随机颜色
    function randomColor() {
        return "rgb(" + (~~(Math.random() * 255)) + "," + (~~(Math.random() * 255)) + "," + (~~(Math
            .random() * 255)) + ")";
    }
}());

CSS

CSS
/* 全局样式 */
        body {
            font-family: 'Inter', sans-serif;
            padding-left: 200px;
            background-color: #f4f4f9;
            margin: 0;
            opacity: 0;
            animation: fadeIn 1s ease-in-out forwards;
            transition: background-color 0.5s ease;
        }

        @keyframes fadeIn {
            from {
                opacity: 0;
            }
            to {
                opacity: 1;
            }
        }

        /* 导航栏样式 */
        nav {
            position: fixed;
            top: 0;
            left: 0;
            bottom: 0;
            width: 200px;
            background-color: #1e40af;
            color: white;
            padding: 20px;
            box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
            transition: background-color 0.5s ease;
        }

        nav ul {
            list-style-type: none;
            padding: 0;
        }

        nav ul li {
            margin-bottom: 15px;
        }

        nav ul li a {
            color: white;
            text-decoration: none;
            transition: color 0.3s ease;
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 8px;
            border-radius: 4px;
        }

        nav ul li a:hover {
            color: #bfdbfe;
            background-color: rgba(255, 255, 255, 0.1);
        }

        /* 文章样式 */
        .post {
            background-color: white;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.05);
            margin-left: 20px;
            transition: transform 0.3s ease, background-color 0.5s ease;
        }

        .post:hover {
            transform: scale(1.02);
        }

        /* 模态框样式 */
        .modal {
            display: none;
            position: fixed;
            z-index: 1;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            overflow: auto;
            background-color: rgba(0, 0, 0, 0.4);
        }

        .modal-content {
            background-color: #fefefe;
            margin: 15% auto;
            padding: 20px;
            border: 1px solid #888;
            width: 80%;
            max-width: 500px;
            border-radius: 8px;
            animation: fadeIn 0.3s;
            transition: background-color 0.5s ease;
        }

        .close {
            color: #aaa;
            float: right;
            font-size: 28px;
            font-weight: bold;
        }

        .close:hover,
        .close:focus {
            color: black;
            text-decoration: none;
            cursor: pointer;
        }

        /* 筛选框样式 */
        #category-filter {
            padding: 8px;
            border: 1px solid #ccc;
            border-radius: 4px;
            margin-bottom: 20px;
            transition: background-color 0.5s ease;
        }

        /* 调整元素布局 */
        .container {
            padding: 20px;
        }

        #search-input {
            margin-left: 20px;
        }


        .me{
            position: sticky;
            top: 10px;

        }

        /* 友情链接样式 */
        .friend-links {
            background-color: white;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.05);
            margin-top: 50px;
            transition: transform 0.3s ease, background-color 0.5s ease;
            position: sticky;
            top: 275px;

        }

        .friend-links:hover {
            transform: scale(1.02);
        }

        .friend-links h2 {
            font-size: 1.25rem;
            font-weight: bold;
            margin-bottom: 10px;
            color: #1e40af;
        }

        .friend-links a {
            display: block;
            color: #1e40af;
            text-decoration: none;
            margin-bottom: 5px;
            transition: color 0.3s ease;
        }

        .friend-links a:hover {
            color: #1d4ed8;
            text-decoration: underline;
        }



        /* 个人中心和通知模态框样式 */
        #profile-modal,
        #notifications-modal {
            display: none;
            position: fixed;
            z-index: 1;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            overflow: auto;
            background-color: rgba(0, 0, 0, 0.4);
        }

        #profile-modal .modal-content,
        #notifications-modal .modal-content {
            background-color: #fefefe;
            margin: 15% auto;
            padding: 20px;
            border: 1px solid #888;
            width: 80%;
            max-width: 500px;
            border-radius: 8px;
            animation: fadeIn 0.3s;
            transition: background-color 0.5s ease;
        }

        /* 通知列表样式 */
        .notification-list {
            list-style-type: none;
            padding: 0;
        }

        .notification-list li {
            border-bottom: 1px solid #ccc;
            padding: 10px 0;
        }

        .notification-list li:last-child {
            border-bottom: none;
        }

HTML

HTML
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="https://cdn.tailwindcss.com"></script>
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css" rel="stylesheet">
    <link href="css.css" rel="stylesheet">
    <title>D_Blog</title>
</head>

<body class="bg-gray-100">
    <nav>
        <a href="#" class="text-2xl font-bold block mb-4">D_Blog</a>
        <ul>
            <li><a href="#"><i class="fa-solid fa-house"></i><span>首页</span></a></li>
            <li><a href="#" id="about-link"><i class="fa-solid fa-user"></i><span>关于我</span></a></li>
            <li><a href="#" id="contact-link"><i class="fa-solid fa-envelope"></i><span>联系我</span></a></li>
            <li><a href="https://hydro.ac/d/nebula_walk/" target="_blank"><i class="fa fa-terminal"></i><span>我的OJ</span></a></li>
            <li><a href="#" id="notifications-link"><i class="fa-solid fa-bell"></i><span>通知</span></a></li>
            <li><a href="#"><i class="fa fa-angle-double-up"></i><span>返回顶端</span></a></li>
        </ul>
    </nav>
    <div class="container mx-auto py-4">
        <input type="text" id="search-input" class="p-2 border border-gray-300 rounded-md" placeholder="搜索文章标题或标签...">
        <!-- 筛选框 -->
        <select id="category-filter">
            <option value="all">全部</option>
            <option value="notice">公告</option>
            <option value="note">笔记</option>
            <option value="other">其他</option>
        </select>
    </div>
    <div class="container mx-auto py-8 flex flex-col md:flex-row">
        <div class="w-full md:w-3/4 pr-4">





            <!-- 为文章添加分类属性 -->
            <!-- 文章代码模版 -->
            <div class="post bg-white p-6 rounded-md shadow-md mb-6" data-category="notice">
                <h2 class="text-2xl font-bold mb-2">公告</h2>
                <p class="text-gray-600 text-sm mb-4">发布于 2025 年 5 月 1 日,最后更新于 2025 年 7 月 25 日</p>
                <p class="text-gray-700">本站是nebula_walk的个人小站,随缘更新。</p>
                <p class="text-gray-700">Update: 修复了一些已知问题</p>
                <p class="text-red-700">置顶</p>
            </div>





            <div class="post bg-white p-6 rounded-md shadow-md mb-6" data-category="other">
                <h2 class="text-2xl font-bold mb-2">随笔-1</h2>
                <p class="text-gray-600 text-sm mb-4">发布于 2025 年 7 月 25 日</p>
                <p class="text-gray-700">好久都没更新博客了,一直在忙着准备CSP,今天浅浅维护一下。。。</p>
                <span class="text-gray-700">--"你已经在洛谷连续打卡了 80 天"</span>
            </div>



            <div class="post bg-white p-6 rounded-md shadow-md mb-6" data-category="note">
                <h2 class="text-2xl font-bold mb-2">笔记-递归</h2>
                <p class="text-gray-600 text-sm mb-4">发布于 2025 年 5 月 10 日</p>
                <p class="text-gray-700">
                    <p>递归(Recursion),又译为递回,是一种在数学与计算机科学中广泛应用的思维方式和技术手段,指的是在函数的定义中使用函数自身的方法。递归通常用于解决那些可以分解为相同问题但规模较小的问题。
                    <p>:::::::主要部分:::::::</p>
                    1.递归边界条件:用于结束递归调用,防止无限循环。
                    <p>2.递归表达式:确保每次调用逐步逼近边界条件。</p>
                    <p>。。。递归的执行依赖于调用栈,这是一种数据结构,记录着每次函数调用的上下文信息,使得每一层的函数调用都可以返回其结果。。。</p></p>
            </div>






           <div class="post bg-white p-6 rounded-md shadow-md mb-6" data-category="note">
                <h2 class="text-2xl font-bold mb-2">笔记-贪心算法</h2>
                <p class="text-gray-600 text-sm mb-4">发布于 2025 年 5 月 9 日</p>
                <p class="text-gray-700">
                    <p>贪心算法(Greedy Algorithm)是一种在每一步选择中都采取当前状态下最优选择,从而希望得到全局最优解的算法策略。
                    <p>工作原理:</p>从问题的初始状态开始,根据贪心策略,在每一步决策中选择当前最优的解决方案,逐步逼近最终目标。一旦做出选择,就不再回溯或重新考虑之前的决策,而是继续基于当前状态进行下一步的贪心选择。
                    <p>应用场景:</p>
                    找零问题,背包问题,活动选择问题,集合覆盖问题。</p>
            </div>




            <div class="post bg-white p-6 rounded-md shadow-md mb-6" data-category="note">
                <h2 class="text-2xl font-bold mb-2">笔记-扩展欧几里得算法</h2>
                <p class="text-gray-600 text-sm mb-4">发布于 2025 年 5 月 5 日</p>
                <p class="text-gray-700">
                    <p>欧几里得算法:</p>对于任意两个非零整数 a和b,有 gcd(a,b)=gcd(b,a mod b) 。这意味着,两个数的最大公约数等于较小数和较大数除以较小数的余数的最大公约数。
                    <p>扩展部分:</p>在计算 gcd(a,b) 的过程中,同时记录每一步的 x 和 y 值,使得最终得到满足 ax+by=gcd(a,b) 的整数解。</p>
            </div>







            <div class="post bg-white p-6 rounded-md shadow-md mb-6" data-category="note">
                <h2 class="text-2xl font-bold mb-2">笔记-路径压缩</h2>
                <p class="text-gray-600 text-sm mb-4">发布于 2025 年 5 月 4 日</p>
                <p class="text-gray-700">   <p>基本概念:</p>在并查集中,每个元素代表一个集合,元素之间的关系通过树形结构表示,每个集合有一个根节点。查找操作(find)用于确定一个元素属于哪个集合,即找到其根节点。
                <p>优化效果:</p>路径压缩能够显著减少查找操作的时间复杂度,理论上可以将树结构的查找时间复杂度从 O(logN) 降低到接近 O(1) ,其中N是集合中元素的数量。这使得并查集在处理大规模数据集时具有更高的效率。</p>
            </div>





        </div>
        <div class="w-full md:w-1/4">
            <div class="bg-white p-6 rounded-md shadow-md mb-6 me">
                <h2 class="text-xl font-bold mb-4">nebula_walk</h2>
                <a href="https://www.luogu.com.cn/user/1456696" target="_blank"><img src="https://cdn.luogu.com.cn/upload/image_hosting/pwdplx2o.png" alt="头像" class="w-24 h-24 rounded-full mx-auto mb-4" target="_blank"></a>
                <p class="text-gray-700 text-center">本站是nebula_walk的个人主页,用于分享我的见解与经验。</p>
            </div>
            <!-- 友情链接 -->
            <div class="friend-links">
                <h2>友情链接</h2>
                <a href="#" id="contact">申请坑位</a>
            </div>
        </div>
    </div>
    <div id="about-modal" class="modal">
        <div class="modal-content">
            <span class="close">&times;</span>
            <h1>关于我</h1>
            <p>我只会告诉你我是__初中生__,因为沉默是金</p>
        </div>
    </div>
    <div id="contact-modal" class="modal">
        <div class="modal-content">
            <span class="close">&times;</span>
            <h1>联系我</h1>
            <p>如果你有任何问题、建议或者合作意向,欢迎通过以下方式联系我:</p>
            <ul>
                <li>邮箱:405578615@qq.com</li>
                <li>click:<a href="https://www.luogu.com.cn/user/1456696" style="color: #1e40af;"target="_blank">MY洛谷</a></li>
            </ul>
        </div>
    </div>
    <div id="notifications-modal" class="modal">
        <div class="modal-content">
            <span class="close">&times;</span>
            <h2>通知</h2>
            <ul class="notification-list">
                <li><a href="https://www.luogu.com.cn/user/1456696#activity" style="color: #1e40af;"target="_blank">nebula_walk发布了新动态,快去看一看</a></li>
            </ul>
        </div>
    </div>
    <!-- 提示框 -->
    <div id="toast" class="toast"></div>
    <footer class="bg-gray-800 p-4 text-white text-center" >
        <p>&copy; 2025 D_Blog. 保留所有权利。</p>
    </footer>
    <script src="js.js">
    </script>
</body>

</html>
原文