乐于分享
好东西不私藏

黑色科技感背景HTML页面!!附源码!!

黑色科技感背景HTML页面!!附源码!!

  效果展示  

  完整源码  

HTML
<!DOCTYPE html><htmllang="zh-CN"><head>    <metacharset="UTF-8">    <metaname="viewport"content="width=device-width, initial-scale=1.0">    <title>黑色科技感背景</title>    <linkhref="css.css"rel="stylesheet" /></head><body>    <divclass="grid"></div>    <canvasclass="particles"id="particles"></canvas>    <divclass="glow-elements">        <divclass="glow-element element1"></div>        <divclass="glow-element element2"></div>        <divclass="glow-element element3"></div>    </div>    <divclass="container">        <h1>未来科技界面</h1>        <pclass="subtitle">探索未知的数字领域,体验前沿科技带来的无限可能</p>        <divclass="tech-card">            <h2>系统状态</h2>            <p>所有系统运行正常,性能优化达到预期水平。量子计算模块已启动,数据加密等级:A级。</p>            <buttonclass="btn">启动深度扫描</button>        </div>    </div>    <scriptsrc="js.js"></script></body></html>
css·CSS
    * {        margin0;        padding0;        box-sizing: border-box;    }    body {        background-color#000;        color#0ef;        font-family'Arial', sans-serif;        overflow: hidden;        height100vh;        position: relative;    }    .container {        position: relative;        width100%;        height100vh;        display: flex;        flex-direction: column;        justify-content: center;        align-items: center;        z-index10;    }    h1 {        font-size3.5rem;        margin-bottom1.5rem;        text-transform: uppercase;        letter-spacing3px;        text-shadow0 0 10px #0ef0 0 20px #0ef0 0 40px #0ef;        animation: pulse 2s infinite alternate;    }    .subtitle {        font-size1.2rem;        margin-bottom2rem;        text-align: center;        max-width600px;        line-height1.6;        text-shadow0 0 5px #0ef;    }    .grid {        position: absolute;        top0;        left0;        width100%;        height100%;        background-image            linear-gradient(rgba(02382550.11px, transparent 1px),            linear-gradient(90degrgba(02382550.11px, transparent 1px);        background-size50px 50px;        z-index1;        animation: gridMove 20s linear infinite;    }    .particles {        position: absolute;        top0;        left0;        width100%;        height100%;        z-index2;    }    .glow-elements {        position: absolute;        top0;        left0;        width100%;        height100%;        z-index3;    }    .glow-element {        position: absolute;        border-radius50%;        backgroundrgba(02382550.2);        box-shadow0 0 40px 10px rgba(02382550.5);        animation: glow 5s infinite alternate;    }    .element1 {        width300px;        height300px;        top10%;        left5%;        animation-delay0s;    }    .element2 {        width200px;        height200px;        bottom10%;        right10%;        animation-delay2.5s;    }    .element3 {        width150px;        height150px;        top50%;        left80%;        animation-delay1s;    }    .tech-card {        backgroundrgba(020300.7);        border1px solid rgba(02382550.5);        border-radius10px;        padding2rem;        margin1rem;        max-width500px;        box-shadow0 0 15px rgba(02382550.3);        backdrop-filterblur(5px);        z-index10;    }    .tech-card h2 {        color#0ef;        margin-bottom1rem;        font-size1.8rem;        text-shadow0 0 5px #0ef;    }    .tech-card p {        color#aaf;        line-height1.6;        margin-bottom1.5rem;    }    .btn {        background: transparent;        border1px solid #0ef;        color#0ef;        padding0.8rem 1.5rem;        border-radius5px;        cursor: pointer;        font-size1rem;        text-transform: uppercase;        letter-spacing1px;        transition: all 0.3s ease;        text-shadow0 0 5px #0ef;        box-shadow0 0 10px rgba(02382550.3);    }    .btn:hover {        backgroundrgba(02382550.2);        box-shadow0 0 15px rgba(02382550.5);    }    @keyframes pulse {        0% {            text-shadow0 0 10px #0ef0 0 20px #0ef0 0 40px #0ef;        }        100% {            text-shadow0 0 5px #0ef0 0 10px #0ef0 0 20px #0ef0 0 30px #0ef;        }    }    @keyframes gridMove {        0% {            background-position0 0;        }        100% {            background-position50px 50px;        }    }    @keyframes glow {        0% {            opacity0.3;            transformscale(1);        }        100% {            opacity0.7;            transformscale(1.1);        }    }    /* 响应式设计 */    @media (max-width768px) {        h1 {            font-size2.5rem;        }        .subtitle {            font-size1rem;            padding0 1rem;        }        .tech-card {            margin1rem;            padding1.5rem;        }    }
js·JS
    // 粒子系统    const canvas = document.getElementById('particles');    const ctx = canvas.getContext('2d');    // 设置Canvas尺寸    function resizeCanvas() {        canvas.width = window.innerWidth;        canvas.height = window.innerHeight;    }    resizeCanvas();    window.addEventListener('resize', resizeCanvas);    // 粒子类    class Particle {        constructor() {            this.x = Math.random() * canvas.width;            this.y = Math.random() * canvas.height;            this.size = Math.random() * 2 + 0.5;            this.speedX = Math.random() * 1 - 0.5;            this.speedY = Math.random() * 1 - 0.5;            this.color = `rgba(0238255, ${Math.random() * 0.5 + 0.1})`;        }        update() {            this.x += this.speedX;            this.y += this.speedY;            // 边界检查            if (this.x > canvas.width) this.x = 0;            if (this.x < 0this.x = canvas.width;            if (this.y > canvas.height) this.y = 0;            if (this.y < 0this.y = canvas.height;        }        draw() {            ctx.fillStyle = this.color;            ctx.beginPath();            ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2);            ctx.fill();        }    }    // 创建粒子    const particles = [];    const particleCount = 150;    for (let i = 0; i < particleCount; i++) {        particles.push(new Particle());    }    // 动画循环    function animate() {        ctx.clearRect(00, canvas.width, canvas.height);        // 绘制连接线        for (let i = 0; i < particles.length; i++) {            for (let j = i; j < particles.length; j++) {                const dx = particles[i].x - particles[j].x;                const dy = particles[i].y - particles[j].y;                const distance = Math.sqrt(dx * dx + dy * dy);                if (distance < 100) {                    ctx.beginPath();                    ctx.strokeStyle = `rgba(0238255, ${0.2 * (1 - distance/100)})`;                    ctx.lineWidth = 0.5;                    ctx.moveTo(particles[i].x, particles[i].y);                    ctx.lineTo(particles[j].x, particles[j].y);                    ctx.stroke();                }            }        }        // 更新和绘制粒子        particles.forEach(particle => {            particle.update();            particle.draw();        });        requestAnimationFrame(animate);    }    animate();    // 添加交互效果    document.querySelector('.btn').addEventListener('click', function() {        this.textContent = '扫描中...';        this.style.boxShadow = '0 0 20px rgba(0, 238, 255, 0.8)';        setTimeout(() => {            this.textContent = '扫描完成';            setTimeout(() => {                this.textContent = '启动深度扫描';                this.style.boxShadow = '0 0 10px rgba(0, 238, 255, 0.3)';            }, 2000);        }, 1500);    });