404 Not Found Page 创意 纯静态页面 仅4kb单文件 home 编辑时间 2021/10/27 ![](https://leanote.zzzmh.cn/api/file/getImage?fileId=61791547da740500130079bd) <br><br> ## 前言 需要一个长的不丑的干净的404和500页面,方便配置到项目中或tomcat/nginx中 最好是个单文件无依赖也不用加载图片,以保持稳定快速,防止连404也炸了 <br> 找了很多 最后相中了这个页面 [https://www.undi.cn/404/404-galaxy-not-found/](https://www.undi.cn/404/404-galaxy-not-found/) 于是在他的基础上再加入了一点点自己的想法 <br> 在线效果预览地址 404 找不到该页面 [404.html](https://res.zzzmh.cn/404.html) 500 服务异常 [500.html](https://res.zzzmh.cn/500.html) <br> ## 折腾 `404.html` ```html <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=0.5"/> <title>404 - 找不到页面</title> <link rel="icon" type="image/x-icon" href="/favicon.ico"/> <style> * { box-sizing: border-box; } body { margin: 0; font-size: 26px; user-select: none } .container { position: relative; display: flex; align-items: center; justify-content: center; height: 100vh; background: white; color: black; font-family: arial, sans-serif; overflow: hidden; } .content { position: relative; width: 650px; max-width: 100%; margin: 30px; background: white; padding: 50px 80px 80px; text-align: center; z-index: 99; box-shadow: -10px 10px 67px -12px rgba(0, 0, 0, 0.2); opacity: 0; animation: apparition 0.5s 0.1s cubic-bezier(0.39, 0.575, 0.28, 0.995) forwards; } .content p { font-size: 1.3rem; margin-top: 0; margin-bottom: 2rem; letter-spacing: 0.1rem; color: #595959; } .content button { display: inline-block; margin-top: 2rem; padding: 0.8rem 1rem; border: 3px solid #595959; background: transparent; font-size: 1.11rem; color: #595959; text-decoration: none; cursor: pointer; font-weight: bolder; } .particle { position: absolute; display: block; pointer-events: none; } @keyframes apparition { from { opacity: 0; transform: translateY(-100px); } to { opacity: 1; transform: translateY(0); } } @keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(200px); } } </style> </head> <body> <main class="container"> <article class="content"> <h1> 404 找不到这个页面 </h1> <p> 抱歉,您要访问的页面已不存在,可能已被删除, 建议返回首页,或者看看我的其他网站 </p> <p> <a href="https://zzzmh.cn/index"> <button>个人博客</button> </a> <a href="https://bz.zzzmh.cn/"> <button>极简壁纸</button> </a> <a href="https://chrome.zzzmh.cn/"> <button>极简插件</button> </a> <a href="https://tool.zzzmh.cn/"> <button>极简工具</button> </a> </p> </article> </main> <script> // 给背景加点好玩的 for (let i = 0; i < 150; i++) { const span = document.createElement('span'); span.className = 'particle'; span.style.top = random(0, 100) + '%'; span.style.left = random(0, 100) + '%'; span.style.fontSize = random(12, 42, true) + 'px'; span.style.filter = 'blur(' + random(0.1, 2.6) + 'px)'; span.style.animation = random(10, 60) + 's float infinite'; span.innerHTML = String.fromCharCode(random(33, 126, true)); span.style.color = 'rgb(' + random(0, 255, true) + ',' + random(0, 255, true) + ',' + random(0, 255, true) + ')'; document.querySelector('.container').appendChild(span); } function random(min, max, isInteger) { const number = Math.random() * (max - min) + min; return isInteger ? Math.floor(number) : number; } </script> </body> </html> ``` <br><br> `500.html` ```html <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=0.5"/> <title>500 - 服务器繁忙</title> <link rel="icon" type="image/x-icon" href="/favicon.ico"/> <style> * { box-sizing: border-box; } body { margin: 0; font-size: 26px; user-select: none } .container { position: relative; display: flex; align-items: center; justify-content: center; height: 100vh; background: white; color: black; font-family: arial, sans-serif; overflow: hidden; } .content { position: relative; width: 650px; max-width: 100%; margin: 30px; background: white; padding: 50px 80px 80px; text-align: center; z-index: 99; box-shadow: -10px 10px 67px -12px rgba(0, 0, 0, 0.2); opacity: 0; animation: apparition 0.5s 0.1s cubic-bezier(0.39, 0.575, 0.28, 0.995) forwards; } .content p { font-size: 1.3rem; margin-top: 0; margin-bottom: 2rem; letter-spacing: 0.1rem; color: #595959; } .content button { display: inline-block; margin-top: 2rem; padding: 0.8rem 1rem; border: 3px solid #595959; background: transparent; font-size: 1.11rem; color: #595959; text-decoration: none; cursor: pointer; font-weight: bolder; } .particle { position: absolute; display: block; pointer-events: none; } @keyframes apparition { from { opacity: 0; transform: translateY(-100px); } to { opacity: 1; transform: translateY(0); } } @keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(200px); } } </style> </head> <body> <main class="container"> <article class="content"> <h1> 500 服务器繁忙 </h1> <p> 抱歉,当前时间服务器繁忙,可能正在维护中,请稍等片刻, 您也可以尝试访问我的其他网站,谢谢 </p> <p> <a href="https://zzzmh.cn/index"> <button>个人博客</button> </a> <a href="https://bz.zzzmh.cn/"> <button>极简壁纸</button> </a> <a href="https://chrome.zzzmh.cn/"> <button>极简插件</button> </a> <a href="https://tool.zzzmh.cn/"> <button>极简工具</button> </a> </p> </article> </main> <script> // 给背景加点好玩的 for (let i = 0; i < 150; i++) { const span = document.createElement('span'); span.className = 'particle'; span.style.top = random(0, 100) + '%'; span.style.left = random(0, 100) + '%'; span.style.fontSize = random(12, 42, true) + 'px'; span.style.filter = 'blur(' + random(0.1, 2.6) + 'px)'; span.style.animation = random(10, 60) + 's float infinite'; span.innerHTML = String.fromCharCode(random(33, 126, true)); span.style.color = 'rgb(' + random(0, 255, true) + ',' + random(0, 255, true) + ',' + random(0, 255, true) + ')'; document.querySelector('.container').appendChild(span); } function random(min, max, isInteger) { const number = Math.random() * (max - min) + min; return isInteger ? Math.floor(number) : number; } </script> </body> </html> ``` ## END 代码非完全原创,大量参考以下地址 <br> [https://404.life/184.html](https://404.life/184.html) <br> 源码Gitee地址 [https://gitee.com/tczmh/ErrorPage404](https://gitee.com/tczmh/ErrorPage404) 送人玫瑰,手留余香 赞赏 Wechat Pay Alipay Oculus Quest 2 VR 国内激活、游戏下载、离线安装 等折腾笔记 WebSocket 入门 Java Springboot + Html5 JavaScript 简单实现