<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>ssss</title>
</head>
<style>
* {
padding: 0px;
}
ul {
list-style: none;
}
a {
text-decoration: none;
}
/*一级菜单样式*/
#nav {
position:absolute;
left:12%;
top:5%;
font-size: 18px;
font-family: 微软雅黑;
width: 75%;
height: 60px;
background-color:#030303;
border-radius:10px ;
border: 10px solid rgba(0,0,0,.1);
box-shadow: 2px 2px 2px 2px rgba(0,0,0,.3);
opacity:0.5;
}
#nav ul li {
float: left;
/*包含块*/
position:relative;
}
#nav ul li a {
display: block;
width: 160px;
height: 40px;
line-height: 40px;
text-align: center;
color: #fff;
}
#nav ul li a:hover {
color: #ffd800;
}
/*二级菜单样式*/
#nav ul ul {
display:none;
width: 18%;
height: 360px;
background-color:#030303;
border-radius:10px ;
border: 10px solid rgba(0,0,0,.1);
box-shadow: 2px 2px 2px 2px rgba(0,0,0,.3);
overflow: hidden;
opacity:0.5;
position:fixed;
}
#nav ul ul {
float:none;
}
#nav ul li ul li a{
}
/*一级菜单悬停时二级菜单可见*/
#nav ul li:hover ul {
display:block;
}
.nav-bar>li:hover a{
color: white;
transform: scale(1.5);
transition: all .5s;
}
.nav-bar a{
display: block;
font-size: 20px;
line-height: 25px;
padding: 0px 60px;
color: #FFFFFF;
}
.nav-bar>li{
float:left;
height:inherit;
text-align: center;
}
.fullscreenvideo {
position: fixed;
top: 50%;
left: 50%;
min-width: 100%;
min-height: 100%;
width: auto;
height: auto;
z-index: -100;
-webkit-transform: translateX(-50%) translateY(-50%);
transform: translateX(-50%) translateY(-50%);
-webkit-transition: 1s opacity;
transition: 1s opacity;
}
.videocontainer{
position: fixed;
width: 100%;
height: 100%;
overflow: hidden;
z-index: -100;
}
.videocontainer:before{
content: "";
position: absolute;
width: 100%;
height: 100%;
display: block;
z-index: -1;
top: 0;
left: 0;
background: rgba(0,0,0,0);
}
</style>
<body>
<div class="videocontainer">
<video class="fullscreenvideo" playsinline="" autoplay="" muted="" loop="">
<source src="https://cdn2-unrealengine-1251447533.file.myqcloud.com/Unreal%20Engine%2Fhome%2FMainPage-81570d63f80f565cfe5992d8ecc0916a19074573.mp4" type="video/mp4">
</video>
</div>
<canvas id="cas" width="840" height="945"></canvas>
<script>
var canvas = document.getElementById("cas");
var ctx = canvas.getContext("2d");
resize();
window.onresize = resize;
function resize() {
canvas.width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
canvas.height = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
}
var RAF = (function() {
return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function(callback) {
window.setTimeout(callback, 1000 / 60);
};
})();
// 鼠标活动时,获取鼠标坐标
var warea = {x: null, y: null, max: 20000};
window.onmousemove = function(e) {
e = e || window.event;
warea.x = e.clientX;
warea.y = e.clientY;
};
window.onmouseout = function(e) {
warea.x = null;
warea.y = null;
};
// 添加粒子
// x,y为粒子坐标,xa, ya为粒子xy轴加速度,max为连线的最大距离
var dots = [];
for (var i = 0; i < 300; i++) {
var x = Math.random() * canvas.width;
var y = Math.random() * canvas.height;
var xa = Math.random() * 2 - 1;
var ya = Math.random() * 2 - 1;
dots.push({
x: x,
y: y,
xa: xa,
ya: ya,
max: 6000
})
}
// 延迟100秒开始执行动画,如果立即执行有时位置计算会出错
setTimeout(function() {
animate();
}, 100);
// 每一帧循环的逻辑
function animate() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
// 将鼠标坐标添加进去,产生一个用于比对距离的点数组
var ndots = [warea].concat(dots);
dots.forEach(function(dot) {
// 粒子位移
dot.x += dot.xa;
dot.y += dot.ya;
// 遇到边界将加速度反向
dot.xa *= (dot.x > canvas.width || dot.x < 0) ? -1 : 1;
dot.ya *= (dot.y > canvas.height || dot.y < 0) ? -1 : 1;
// 绘制点
ctx.fillRect(dot.x - 0.5, dot.y - 0.5, 2, 2);
// 循环比对粒子间的距离
for (var i = 0; i < ndots.length; i++) {
var d2 = ndots[i];
if (dot === d2 || d2.x === null || d2.y === null) continue;
var xc = dot.x - d2.x;
var yc = dot.y - d2.y;
// 两个粒子之间的距离
var dis = xc * xc + yc * yc;
// 距离比
var ratio;
// 如果两个粒子之间的距离小于粒子对象的max值,则在两个粒子间画线
if (dis < d2.max) {
// 如果是鼠标,则让粒子向鼠标的位置移动
if (d2 === warea && dis > (d2.max / 2)) {
dot.x -= xc * 0.03;
dot.y -= yc * 0.03;
}
// 计算距离比
ratio = (d2.max - dis) / d2.max;
// 画线
ctx.beginPath();
ctx.lineWidth = ratio/2;
//线条颜色
ctx.strokeStyle = 'rgba(255,251,240)';
ctx.fillStyle = 'rgba(255,251,240)';
ctx.moveTo(dot.x, dot.y);
ctx.lineTo(d2.x, d2.y);
ctx.stroke();
}
}
// 将已经计算过的粒子从数组中删除
ndots.splice(ndots.indexOf(dot), 1);
});
RAF(animate);
}
</script>
<div id="nav">
<ul class="nav-bar">
<li><a>兴趣爱好</a>
<ul>
<li><a>SkateBoard</a></li>
<li><a>PlayGames</a></li>
<li><a>Art</a></li>
</ul>
</li>
<li><a>情感状况</a>
<ul>
<li><a href="https://baike.baidu.com/item/%E5%8D%95%E8%BA%AB%E7%8B%97/16528775?fr=aladdin" target="_blank">单</a></li>
<li><a href="https://baike.baidu.com/item/%E5%8D%95%E8%BA%AB%E7%8B%97/16528775?fr=aladdin" target="_blank">身</a></li>
<li><a href="https://baike.baidu.com/item/%E5%8D%95%E8%BA%AB%E7%8B%97/16528775?fr=aladdin" target="_blank">🐕</a></li>
</ul>
</li>
<li><a>专业能力</a>
<ul>
<li><a href="https://baike.baidu.com/item/html5/4234903?fr=aladdin" target="_blank">HTML5</a></li>
<li><a href="https://baike.baidu.com/item/Java/85979?fr=aladdin" target="_blank">JAVA</a></li>
<li><a href="https://baike.baidu.com/item/Python/407313?fr=aladdin" target="_blank">PYTHON</a></li>
</ul>
</li>
<li><a>联系方式</a>
<ul>
<li><a href="http://wpa.qq.com/msgrd?v=3&uin=您的qq号&site=qq&menu=yes" target="_blank"><font size="1">QQ:96xxxxx93</font></a></li>
<li><a><font size="1">E-Mail:@qq.com</font></a></li>
<li><a><font size="1">PhoneNum:</font></a></li>
</ul>
</li>
</div>
</body>
</html>
在小窗口模式会有显示的问题没有修改,自己可以查百度改一改就好了。