编写简单的 404 界面,也可以用来做 500 报错界面,还会飘东西,特别好,蛮漂亮的!

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>404</title> <style>
html, body {
height: 100%;
min-height: 450px;
font-size: 32px;
font-weight: 500;
color: #5d7399;
margin: 0;
padding: 0;
border: 0;
} .content {
height: 100%;
position: relative;
z-index: 1;
background-color: #d2e1ec;
background-image: -webkit-linear-gradient(top, #bbcfe1 0%, #e8f2f6 80%);
background-image: linear-gradient(to bottom, #bbcfe1 0%, #e8f2f6 80%);
overflow: hidden;
} .snow {
position: absolute;
top: 0;
left: 0;
pointer-events: none;
z-index: 20;
} .main-text {
padding: 20vh 20px 0 20px;
text-align: center;
line-height: 2em;
font-size: 5vh;
} .main-text h1 {
font-size: 45px;
line-height: 48px;
margin: 0;
padding: 0;
} .main-text-a {
height: 32px;
margin-left: auto;
margin-right: auto;
text-align: center;
} .main-text-a a {
font-size: 16px;
text-decoration: none;
color: #0066CC;
} .main-text-a a:hover {
color: #000;
} .home-link {
font-size: 0.6em;
font-weight: 400;
color: inherit;
text-decoration: none;
opacity: 0.6;
border-bottom: 1px dashed rgba(93, 115, 153, 0.5);
} .home-link:hover {
opacity: 1;
} .ground {
height: 160px;
width: 100%;
position: absolute;
bottom: 0;
left: 0;
background: #f6f9fa;
box-shadow: 0 0 10px 10px #f6f9fa;
} .ground:before, .ground:after {
content: '';
display: block;
width: 250px;
height: 250px;
position: absolute;
top: -62.5px;
z-index: -1;
background: transparent;
-webkit-transform: scaleX(0.2) rotate(45deg);
transform: scaleX(0.2) rotate(45deg);
} .ground:after {
left: 50%;
margin-left: -166.66667px;
box-shadow: -340px 260px 15px #8193b2, -620px 580px 15px #8193b2, -900px 900px 15px #b0bccf, -1155px 1245px 15px #b4bed1, -1515px 1485px 15px #8193b2, -1755px 1845px 15px #8a9bb8, -2050px 2150px 15px #91a1bc, -2425px 2375px 15px #bac4d5, -2695px 2705px 15px #a1aec6, -3020px 2980px 15px #8193b2, -3315px 3285px 15px #94a3be, -3555px 3645px 15px #9aa9c2, -3910px 3890px 15px #b0bccf, -4180px 4220px 15px #bac4d5, -4535px 4465px 15px #a7b4c9, -4840px 4760px 15px #94a3be;
} .ground:before {
right: 50%;
margin-right: -166.66667px;
box-shadow: 325px -275px 15px #b4bed1, 620px -580px 15px #adb9cd, 925px -875px 15px #a1aec6, 1220px -1180px 15px #b7c1d3, 1545px -1455px 15px #7e90b0, 1795px -1805px 15px #b0bccf, 2080px -2120px 15px #b7c1d3, 2395px -2405px 15px #8e9eba, 2730px -2670px 15px #b7c1d3, 2995px -3005px 15px #9dabc4, 3285px -3315px 15px #a1aec6, 3620px -3580px 15px #8193b2, 3880px -3920px 15px #aab6cb, 4225px -4175px 15px #9dabc4, 4510px -4490px 15px #8e9eba, 4785px -4815px 15px #a7b4c9;
} .mound {
margin-top: -80px;
font-weight: 800;
font-size: 180px;
text-align: center;
color: #dd4040;
pointer-events: none;
} .mound:before {
content: '';
display: block;
width: 600px;
height: 200px;
position: absolute;
left: 50%;
margin-left: -300px;
top: 50px;
z-index: 1;
border-radius: 100%;
background-color: #e8f2f6;
background-image: -webkit-linear-gradient(top, #dee8f1, #f6f9fa 60px);
background-image: linear-gradient(to bottom, #dee8f1, #f6f9fa 60px);
} .mound:after {
content: '';
display: block;
width: 28px;
height: 6px;
position: absolute;
left: 50%;
margin-left: -150px;
top: 68px;
z-index: 2;
background: #dd4040;
border-radius: 100%;
-webkit-transform: rotate(-15deg);
transform: rotate(-15deg);
box-shadow: -56px 12px 0 1px #dd4040, -126px 6px 0 2px #dd4040, -196px 24px 0 3px #dd4040;
} .mound_text {
-webkit-transform: rotate(6deg);
transform: rotate(6deg);
} .mound_spade {
display: block;
width: 35px;
height: 30px;
position: absolute;
right: 50%;
top: 42%;
margin-right: -250px;
z-index: 0;
-webkit-transform: rotate(35deg);
transform: rotate(35deg);
background: #dd4040;
} .mound_spade:before, .mound_spade:after {
content: '';
display: block;
position: absolute;
} .mound_spade:before {
width: 40%;
height: 30px;
bottom: 98%;
left: 50%;
margin-left: -20%;
background: #dd4040;
} .mound_spade:after {
width: 100%;
height: 30px;
top: -55px;
left: 0%;
box-sizing: border-box;
border: 10px solid #dd4040;
border-radius: 4px 4px 20px 20px;
}
</style> </head> <body translate="no">
<div class="content">
<canvas class="snow" id="snow" width="1349" height="400"></canvas>
<div class="main-text">
<h1>404 天呐!出错了 ~<br><br>您好像去了一个不存在的地方! (灬ꈍ ꈍ灬)</h1>
<div class="main-text-a"><a href="#">< 返回 首页</a></div>
</div>
<div class="ground">
<div class="mound">
<div class="mound_text">404</div>
<div class="mound_spade"></div>
</div>
</div>
</div> <script>
(function () {
function ready(fn) {
if (document.readyState != 'loading') {
fn();
} else {
document.addEventListener('DOMContentLoaded', fn);
}
} function makeSnow(el) {
var ctx = el.getContext('2d');
var width = 0;
var height = 0;
var particles = []; var Particle = function () {
this.x = this.y = this.dx = this.dy = 0;
this.reset();
} Particle.prototype.reset = function () {
this.y = Math.random() * height;
this.x = Math.random() * width;
this.dx = (Math.random() * 1) - 0.5;
this.dy = (Math.random() * 0.5) + 0.5;
} function createParticles(count) {
if (count != particles.length) {
particles = [];
for (var i = 0; i < count; i++) {
particles.push(new Particle());
}
}
} function onResize() {
width = window.innerWidth;
height = window.innerHeight;
el.width = width;
el.height = height; createParticles((width * height) / 10000);
} function updateParticles() {
ctx.clearRect(0, 0, width, height);
ctx.fillStyle = '#f6f9fa'; particles.forEach(function (particle) {
particle.y += particle.dy;
particle.x += particle.dx; if (particle.y > height) {
particle.y = 0;
} if (particle.x > width) {
particle.reset();
particle.y = 0;
} ctx.beginPath();
ctx.arc(particle.x, particle.y, 5, 0, Math.PI * 2, false);
ctx.fill();
}); window.requestAnimationFrame(updateParticles);
} onResize();
updateParticles();
} ready(function () {
var canvas = document.getElementById('snow');
makeSnow(canvas);
});
})();
</script> </body>
</html>

上边的代码实现了下面的效果,不需要图片,额外的 js 脚本辅助,而且文字修改起来比较方便

  

HTML 和 JavaScript 编写简单的 404 界面的更多相关文章

  1. JavaScript编写简单的抽奖程序

    1.需求说明 某公司年终抽奖,需要有如下功能 1)可以根据实际情况设置到场人数的最大值 2) 点击“开始”,大屏幕滚动,点击“停止”,获奖者的编号出现在大屏幕上 3)在界面里显示全部奖项获奖人编号 4 ...

  2. 学习笔记之javascript编写简单计算器

      感觉自己的的实力真的是有待提高,在编写计算器的过程中,出现了各种各样的问题,暴露了自己的基础不扎实,逻辑思维能力不够,学得知识不能运用到自己的demo中区.先介绍一些这个这个计算器的整体思路.大致 ...

  3. 用JavaScript编写简单斗地主效果Es6

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  4. JavaScript编写简单的增加与减少元素

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  5. 用javascript编写简单银行取钱存钱流程(函数)

    const readline = require('readline-sync')//引用readline-sync let arr = [[], []]; //登陆 let add = functi ...

  6. artDialog是一个基于javascript编写的对话框组件,它拥有精致的界面与友好的接口

    artDialog是一个基于javascript编写的对话框组件,它拥有精致的界面与友好的接口 自适应内容 artDialog的特殊UI框架能够适应内容变化,甚至连外部程序动态插入的内容它仍然能自适应 ...

  7. 编写最简单的 iPhone 界面切换应用

    编写最简单的 iPhone 界面切换应用   以下是在iOS中最简单的界面切换示例.使用了多个Controller,并演示Controller之间在切换界面时的代码处理. 实现的应用界面: 首先,创建 ...

  8. javascript编写一个简单的编译器(理解抽象语法树AST)

    javascript编写一个简单的编译器(理解抽象语法树AST) 编译器 是一种接收一段代码,然后把它转成一些其他一种机制.我们现在来做一个在一张纸上画出一条线,那么我们画出一条线需要定义的条件如下: ...

  9. Django 编写自定义的 404 / 500 报错界面

    Django 编写自定义的 404 / 500 报错界面 1. 首先 setting.py 文件中的 debug 参数设置成 false ,不启用调试. DEBUG = False 2. 在 temp ...

随机推荐

  1. Oracle安装部署之RedHat安装Oracle11g_R2

    硬件配置 内存 :≥1G 硬盘空间:≥10G 上传oracle11g安装包: putty上用wcw用户登录,通过ftp服务上传oracle安装文件到/home/wcw目录下解压 #unzip linu ...

  2. Unified Modeling Language

    https://en.wikipedia.org/wiki/Unified_Modeling_Language

  3. How MySQL Uses Indexes CREATE INDEX SELECT COUNT(*)

    MySQL :: MySQL 5.7 Reference Manual :: 9.3.1 How MySQL Uses Indexeshttps://dev.mysql.com/doc/refman/ ...

  4. Servlet----------在 Servlet 中的xml配置

    今天弄了大半天,才弄好了,还是请教了别人,主要原因在于把web.xml文件放在了WEB-INF文件夹下面了,正常的情况是在WebRoot下面的. 还有一个,我是在MyEclipse中操作的,起初不知道 ...

  5. mysql 内置功能 存储过程介绍

    存储过程介绍 就是mysql内置功能把逻辑写好 的功能给封装好,封装成一个接口名,把接口名丢给应用程序,应用程序直接调用接口名实现一系列增删改查功能 这个接口叫存储过程 基于存储过程封装成一个功能 存 ...

  6. 004-redis-命令-哈希操作,列表操作

    Redis hash 命令 下表列出了 redis hash 基本的相关命令: 序号 命令及描述 1 HDEL key field1 [field2] 删除一个或多个哈希表字段 2 HEXISTS k ...

  7. windows server r2 搭建 ftp服务器

    1:安装ftp服务器 开始>管理工具>服务器管理器>打开服务器管理器,找到添加角色,然后点击,弹出添加角色对话框,选择下一步>选择Web服务器(IIS),然后选择FTP服务,直 ...

  8. Andrew Ng-ML习题答案1

    1.Linear Regression with Multiple Variables 转自:https://blog.csdn.net/mupengfei6688/article/details/5 ...

  9. C++静态数据成员与静态成员函数

    一般情况下,如果有n个同类的对象,那么每一个对象都分别有自己的数据成员,不同对象的数据成员各自有值,互不相干.但是有时人们希望有某一个或几个数据成员为所有对象所共有,这样可以实现数据共享. 可以使用全 ...

  10. C语言进阶之路(三)----野指针的产生原因及解决办法

    1.会产生野指针的做法 #include <stdio.h> //这就是一种错误的写法 int main(){ int *p = NULL; p = (); //释放P所指向的内存空间,但 ...