炫酷HTML蜘蛛侠登录页面

全篇使用HTML、CSS、JavaScript,建议有过基础的进行阅读。

一、预览图

二、HTML代码

html 复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>蜘蛛侠登录界面</title>
    <link rel="stylesheet" href="styles.css">
</head>
<body>
    <div class="center-container">
        <div class="login-container">
            <div class="spiderman-logo">
                <img src="logo.png" alt="Spider-Man Logo">
            </div>
            <h2>欢迎回家</h2>
            <form class="login-form">
                <div class="input-group">
                    <label for="username">用户名</label>
                    <input type="text" id="username" placeholder="输入你的用户名">
                </div>
                <div class="input-group">
                    <label for="password">密码</label>
                    <input type="password" id="password" placeholder="输入你的密码">
                </div>
                <button type="submit">登录</button>
            </form>
        </div>
    </div>

    <canvas id="spider-web"></canvas>

    <script src="script.js"></script>
</body>
</html>

三、CSS代码

css 复制代码
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    background-color: #0A0A2A;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
    position: relative;
    color: white;
}

.center-container {
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2;
    position: relative;
}

.login-container {
    background: linear-gradient(145deg, #c8102e, #0a0a2a);
    padding: 40px;
    border-radius: 15px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
    text-align: center;
    width: 300px;
    z-index: 2;
}

.spiderman-logo img {
    width: 50px;
    height: 60px;
    margin-bottom: 5px;
}

/* Form styles */
.login-form {
    display: flex;
    flex-direction: column;
}

.input-group {
    margin-bottom: 20px;
}

.input-group label {
    margin-bottom: 8px;
    font-size: 14px;
    float: left;
}

.input-group input {
    width: 100%;
    padding: 10px;
    border: none;
    border-radius: 5px;
    background-color: #ffffff;
    color: black;
    font-size: 16px;
}

button {
    padding: 10px 20px;
    border: none;
    background-color: #ff4c4c;
    color: white;
    font-size: 18px;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

button:hover {
    background-color: #ff1c1c;
}

#spider-web {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
    width: 100vw;
    height: 100vh;
}

四、JavaScript代码

javascript 复制代码
const canvas = document.getElementById('spider-web');
const ctx = canvas.getContext('2d');

canvas.width = window.innerWidth;
canvas.height = window.innerHeight;

function drawWeb() {
    const centerX = canvas.width / 2;
    const centerY = canvas.height / 2;
    const radiusStep = 30;
    const radialStep = 10;
    const rings = 10;
    const lines = 12;

    for (let i = 1; i <= rings; i++) {
        ctx.beginPath();
        ctx.arc(centerX, centerY, radiusStep * i, 0, Math.PI * 2);
        ctx.strokeStyle = 'white';
        ctx.lineWidth = 1;
        ctx.stroke();
    }

    for (let i = 0; i < lines; i++) {
        const angle = (i / lines) * Math.PI * 2;
        const x = centerX + Math.cos(angle) * radiusStep * rings;
        const y = centerY + Math.sin(angle) * radiusStep * rings;
        ctx.beginPath();
        ctx.moveTo(centerX, centerY);
        ctx.lineTo(x, y);
        ctx.strokeStyle = 'white';
        ctx.lineWidth = 1;
        ctx.stroke();
    }

    for (let i = 1; i < rings; i++) {
        for (let j = 0; j < lines; j++) {
            const angle1 = (j / lines) * Math.PI * 2;
            const angle2 = ((j + 1) / lines) * Math.PI * 2;
            const x1 = centerX + Math.cos(angle1) * radiusStep * i;
            const y1 = centerY + Math.sin(angle1) * radiusStep * i;
            const x2 = centerX + Math.cos(angle2) * radiusStep * i;
            const y2 = centerY + Math.sin(angle2) * radiusStep * i;

            ctx.beginPath();
            ctx.moveTo(x1, y1);
            ctx.lineTo(x2, y2);
            ctx.strokeStyle = 'white';
            ctx.lineWidth = 1;
            ctx.stroke();
        }
    }
}

drawWeb();
相关推荐
程序员Sunday8 小时前
JavaScript 事件循环面试题,宏任务与微任务怎么执行|Sunday面试指南
开发语言·javascript·面试·校招·事件循环·程序员sunday
Setsuna_F_Seiei9 小时前
前端转型 Agent 开发 06 之 Agent Memory 记忆系统(让 Agent 更智能,更懂你)
前端·agent·ai编程
zhangzeyuaaa9 小时前
Ruby 多线程、GVL(GIL)与 Mutex 完全指南
开发语言·前端·ruby
默_笙10 小时前
🌊 向量库和 ES 都查不出"关系",我只好给奶茶建了一张人脉网
前端·javascript
优选资讯10 小时前
标签打印软件怎么对接 Excel 数据
前端·excel
思无邪6610 小时前
用 AI 做 JS 逆向:从抓包到复现的完整方法论
开发语言·javascript·人工智能
一个风轻云淡11 小时前
GCC 和 GDB命令简单解读
java·linux·前端
u01110267512 小时前
图片处理接口如何统一错误信息 前端提示与后端错误码设计
前端·状态模式
福兮说12 小时前
浏览器里把 iPhone 的 HEIC 转成 JPG:Chrome 解不开、转完大了七成、拍摄时间全丢,六个坑实测
前端·javascript·图像处理·chrome·ios·iphone·heic
libokaifa12 小时前
把语音模型塞进手机:sherpa-onnx 在 Android 上的 ASR / TTS
前端