網(wǎng)站404頁面的目的是告訴瀏覽者其所請求的頁面不存在或鏈接錯誤,同時引導用戶使用瀏覽網(wǎng)站的其他頁面而不是關閉網(wǎng)頁離開。自定義404錯誤頁面是增強用戶體驗的很好的做法,花時間去設計一個創(chuàng)意的404錯誤頁面是一件非常值得的事情,盡管這個頁面被看到的概率很小。
上圖的404錯誤頁面是不是很漂亮?那么使用zblog的同學要如何將這個頁面添加到自己的網(wǎng)站中呢? 首先我們打開主題所在的文件夾下的template文件夾,在里面新建一個404.php文件,然后將以下代碼添加的文件中。
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8"/>
- <meta http-equiv="Cache-Control" content="no-transform"/>
- <meta http-equiv="Content-Language" content="{$language}" />
- <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
- <title>對不起,頁面未找到</title>
- <style type='text/css'>
- body{font:12px/1.5 'Microsoft Yahei',Simsun;font-size:14px;line-height:1.42857143;color:#333;background:#f5f5f5}
- .wrapper-page{width:420px;margin:7.5% auto;text-align:center}
- .page-ex h1{font-size:98px;line-height:150px;font-weight:700;color:#252932;margin:10px 0;text-shadow:rgba(61,61,61,.3) 1px 1px,rgba(61,61,61,.2) 2px 2px,rgba(61,61,61,.3) 3px 3px}
- .page-ex h2{font-size:30px;color:#505458;line-height:35px;margin:10px 0}
- .page-ex p{font-size:14px;color:#505458;margin:0 0 10px}
- input[type=text]{float:left;width:71%;position:relative;font-size:14px;color:rgba(0,0,0,.6);margin-left:-1px;margin-bottom:0;padding:12px 17px;line-height:1.3333333;background-color:#fafafa;-webkit-border-radius:2px;-moz-border-radius:2px;border-radius:2px;-webkit-box-shadow:inset 0 1px 2px rgba(0,0,0,.1);-moz-box-shadow:inset 0 1px 2px rgba(0,0,0,.1);box-shadow:inset 0 1px 2px rgba(0,0,0,.1);border:1px solid #eee;box-shadow:none;outline:0;z-index:2}
- input[type=submit]{width:20%;font-size:16px;font-weight:700;color:#fff;line-height:32px;padding:10px 16px;line-height:1.3333333;border-radius:6px;padding-right:15px;border:2px solid #BDBDBD;background:#BDBDBD;outline:0;cursor:pointer;background-color:#1e88e5;border:1px solid #1e88e5;border-radius:2px;letter-spacing:.2px;opacity:.93;-webkit-box-shadow:0 1px 2px 0 rgba(0,0,0,.1);-moz-box-shadow:0 1px 2px 0 rgba(0,0,0,.1);box-shadow:0 1px 2px 0 rgba(0,0,0,.1);-webkit-transition:all .3s ease-out;-moz-transition:all .3s ease-out;-o-transition:all .3s ease-out;-ms-transition:all .3s ease-out;transition:all .3s ease-out}
- .page-back{background-color:#7e57c2;color:#FFF;letter-spacing:.2px;opacity:.93;display:inline-block;padding:6px 12px;margin-bottom:0;font-size:14px;font-weight:400;line-height:1.42857143;text-align:center;border:1px solid transparent;border-radius:4px;text-decoration:none;-webkit-transition:all .3s ease-out;-moz-transition:all .3s ease-out;-o-transition:all .3s ease-out;-ms-transition:all .3s ease-out;transition:all .3s ease-out}
- .page-back:hover,input[type=submit]:hover{opacity:1;-webkit-box-shadow:0 2px 5px 0 rgba(0,0,0,.16),0 2px 10px 0 rgba(0,0,0,.12);-moz-box-shadow:0 2px 5px 0 rgba(0,0,0,.16),0 2px 10px 0 rgba(0,0,0,.12);box-shadow:0 2px 5px 0 rgba(0,0,0,.16),0 2px 10px 0 rgba(0,0,0,.12)}
- @media only screen and (max-width:767px){.wrapper-page{width:90%}
- }
- @media only screen and (max-width:480px){.wrapper-page{width:90%}
- input[type=text]{width:61%}
- }
- </style>
- </head>
- <body>
- <div class="wrapper-page">
- <div class="page-ex">
- <h1>404!</h1>
- <h2>對不起,頁面未找到</h2><br>
- <p>找不到內容?嘗試下我們的搜索吧!</p>
- <form name="search" method="post" action="{$host}zb_system/cmd.php?act=search">
- <input type="text" name="q" size="11">
- <input type="submit" value="搜索">
- </form>
- <br>
- <a class="page-back" href="{$host}">返回首頁</a>
- </div>
- </div>
- </body>
- </html>
保存文件后,打開網(wǎng)站后臺首頁點擊[清空緩存并重新編譯模板],然后訪問前臺頁面看下404錯誤頁面的效果吧!