简单的404页面代码:
<!DOCTYPE html> <html> <head> <title>404 Page Not Found</title> <style> body { margin: 0; padding: 0; background: #f2f2f2; font-family: Arial, sans-serif; } .container { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh; background: linear-gradient(to right, #3946dc, #ff4b2b); background-size: 400% 400%; animation: gradient 10s ease infinite; } @keyframes gradient { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } } h1 { font-size: 10em; color: #fff; margin: 0; text-shadow: 2px 2px #000; } p { font-size: 2em; color: #fff; margin: 0; margin-top: 20px; text-shadow: 1px 1px #000; } a { font-size: 3.6em; color: #fff; margin-top: 20px; text-decoration: none; border: 2px solid #fff; padding: 10px 20px; border-radius: 5px; transition: all 0.3s ease; } a:hover { background: #fff; color: #ff4b2b; } @media screen and (max-width: 768px) { h1 { font-size: 10em; } p { font-size: 2em; } a { font-size: 3em; } } </style> </head> <body> <div class="container"> <h1>404</h1> <p>Page Not Found</p> <a href="/" target="_blank">点击访问网站首页</a> </div> <!-- 统计代码 --> </body> </html>
直接替换宝塔默认404页面,另外一些CMS,如EYOUCMS,直接替换/public/errpage/目录下的404文件;PBOOTCMS替换/core/template/error.html文件!