HTML+CSS 登录页面(记得收藏)

简介: HTML+CSS 登录页面(记得收藏)

效果




完整代码

<div class="background"></div>
    <div class="login-container">
        <div class="login-card">
            <h1>登录</h1>
            <div class="input-group">
                <input type="text" required>
                <label>用户名</label>
            </div>
            <div class="input-group">
                <input type="password" required>
                <label>密码</label>
            </div>
            <button type="submit" class="btn">进入系统</button>
        </div>
    </div>
 <script>
        document.addEventListener('DOMContentLoaded', (event) => {
            const background = document.querySelector('.background');
            const colors = ['#ff00ff', '#00ffff', '#ff00aa', '#aa00ff', '#ff0066'];
            for (let i = 0; i < 50; i++) {
                const line = document.createElement('div');
                line.classList.add('neon-line');
                line.style.width = `${Math.random() * 300 + 50}px`;
                line.style.height = '2px';
                line.style.top = `${Math.random() * 100}%`;
                line.style.left = `${Math.random() * 100}%`;
                line.style.transform = `rotate(${Math.random() * 360}deg)`;
                line.style.animationDelay = `${Math.random() * 4}s`;
                background.appendChild(line);
            }
            let hue = 0;
            const animateBackground = () => {
                hue = (hue + 1) % 360;
                background.style.background = `linear-gradient(${hue}deg, ${colors[0]}, ${colors[1]}, ${colors[2]}, ${colors[3]}, ${colors[4]})`;
                background.style.backgroundSize = '400% 400%';
                background.style.animation = 'gradient 15s ease infinite';
                requestAnimationFrame(animateBackground);
            };
            animateBackground();
            const loginContainer = document.querySelector('.login-container');
            document.addEventListener('mousemove', (e) => {
                const { clientX, clientY } = e;
                const { innerWidth, innerHeight } = window;
                const x = (clientX - innerWidth / 2) / 25;
                const y = (clientY - innerHeight / 2) / 25;
                loginContainer.style.transform = `rotateY(${-x}deg) rotateX(${y}deg)`;
            });
        });
        const inputs = document.querySelectorAll('input');
        inputs.forEach(input => {
            input.addEventListener('focus', () => {
                input.parentNode.classList.add('focus');
            });
            input.addEventListener('blur', () => {
                if (input.value === '') {
                    input.parentNode.classList.remove('focus');
                }
            });
        });
    </script>

<style>
        @import url('https://fonts.googleapis.com/css2?family=Rajdhani:wght@300;400;500;600;700&display=swap');
        :root {
            --primary-color: #ff00ff;
            --secondary-color: #00ffff;
            --background-color: #000000;
            --text-color: #ffffff;
        }
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        body {
            font-family: 'Rajdhani', sans-serif;
            background-color: var(--background-color);
            color: var(--text-color);
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            overflow: hidden;
            perspective: 1000px;
        }
        .login-container {
            position: relative;
            width: 400px;
            height: 500px;
            transform-style: preserve-3d;
            transform: rotateY(-30deg);
            transition: transform 0.5s ease;
        }
        .login-card {
            position: absolute;
            width: 100%;
            height: 100%;
            background: rgba(255, 255, 255, 0.1);
            border: 2px solid rgba(255, 255, 255, 0.1);
            border-radius: 20px;
            backdrop-filter: blur(5px);
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            padding: 40px;
            transform-style: preserve-3d;
            transition: transform 0.5s ease, box-shadow 0.5s ease;
        }
        .login-card:hover {
            transform: translateZ(50px);
            box-shadow: 0 0 30px var(--primary-color), 0 0 30px var(--secondary-color);
        }
        h1 {
            font-size: 2.5em;
            margin-bottom: 20px;
            transform: translateZ(40px);
            text-shadow: 0 0 10px var(--primary-color), 0 0 20px var(--secondary-color);
        }
        .input-group {
            position: relative;
            width: 100%;
            margin-bottom: 30px;
        }
        input {
            width: 100%;
            padding: 10px 5px;
            background: transparent;
            border: none;
            border-bottom: 2px solid var(--text-color);
            color: var(--text-color);
            font-size: 16px;
            outline: none;
            transition: border-color 0.3s, box-shadow 0.3s;
        }
        input:focus {
            border-bottom-color: var(--primary-color);
            box-shadow: 0 4px 6px rgba(255, 0, 255, 0.1);
        }
        label {
            position: absolute;
            top: 0;
            left: 5px;
            font-size: 16px;
            pointer-events: none;
            transition: 0.3s ease all;
        }
        input:focus ~ label,
        input:valid ~ label {
            top: -20px;
            font-size: 12px;
            color: var(--primary-color);
        }
        .btn {
            background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
            border: none;
            color: var(--background-color);
            padding: 12px 30px;
            font-size: 16px;
            cursor: pointer;
            border-radius: 50px;
            transition: all 0.3s ease;
            text-transform: uppercase;
            letter-spacing: 2px;
            transform: translateZ(20px);
            box-shadow: 0 0 15px rgba(255, 0, 255, 0.5);
        }
        .btn:hover {
            transform: translateZ(30px) scale(1.1);
            box-shadow: 0 0 30px var(--primary-color), 0 0 30px var(--secondary-color);
        }
        .background {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: -1;
            opacity: 0.5;
        }
        @keyframes gradient {
            0% {
                background-position: 0% 50%;
            }
            50% {
                background-position: 100% 50%;
            }
            100% {
                background-position: 0% 50%;
            }
        }
        .neon-line {
            position: absolute;
            background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
            filter: blur(5px);
            opacity: 0;
            animation: neon-flash 4s infinite;
        }
        @keyframes neon-flash {
            0%, 100% { opacity: 0; }
            50% { opacity: 1; }
        }
    </style>
相关文章
|
8天前
|
Web App开发 前端开发 JavaScript
HTML/CSS/JS学习笔记 Day3(HTML--网页标签 下)
HTML/CSS/JS学习笔记 Day3(HTML--网页标签 下)
|
5天前
|
XML JavaScript 前端开发
JavaWeb基础4——HTML,JavaScript&CSS
HTML,JavaScript&CSS、元素、标签、css 选择器、属性、JavaScript基础语法、JavaScript对象、BOM浏览器对象模型、DOM文档对象模型、事件监听、正则对象RegExp/ES6
JavaWeb基础4——HTML,JavaScript&CSS
|
18天前
|
移动开发 JavaScript 前端开发
揭秘!如何用Web2py+HTML5/CSS3/jQuery打造超炫响应式网站?你的设计梦想即将照进现实!
【8月更文挑战第31天】本文详细介绍如何利用Web2py框架及HTML5、CSS3与jQuery构建响应式网站。首先需安装Python和Web2py,并启动服务器。接着,在Web2py中创建新应用,例如命名为“ResponsiveSite”。随后,编写HTML5基本结构,包括头部、导航栏等元素。在`styles.css`文件中添加CSS3样式代码,实现响应式布局。最后,通过在`scripts.js`中加入jQuery脚本提升页面交互性,如点击导航项时平滑滚动至目标区域。此教程为你打下响应式网站设计的基础,便于进一步扩展和优化。
10 1
|
20天前
|
数据安全/隐私保护
自定义密码访问跳转页面HTML源码
自定义密码访问跳转页面HTML源码,源码由HTML+CSS+JS组成,记事本打开源码文件可以进行内容文字之类的修改,双击html文件可以本地运行效果,也可以上传到服务器里面,重定向这个界面
34 0
自定义密码访问跳转页面HTML源码
|
21天前
|
移动开发 前端开发 JavaScript
HTML与CSS二三事
HTML与CSS二三事
|
26天前
|
移动开发 HTML5
HTML5页面元素及属性
【8月更文挑战第23天】HTML5页面元素及属性。
33 4
|
4天前
|
XML 前端开发 JavaScript
jQuery HTML / CSS 方法
jQuery HTML / CSS 方法
9 0
|
18天前
|
前端开发 JavaScript 搜索推荐
打造个人博客网站:从零开始的HTML、CSS与JavaScript之旅
在这个数字时代,拥有一个个性化的网络空间已成为许多人的梦想。本文将引导你了解如何从零开始,使用HTML、CSS和JavaScript创建属于自己的博客网站。我们将探索这些技术的基础概念,并通过实际代码示例展示如何将静态页面转变为动态交互式网站。无论你是编程新手还是希望扩展技能的开发者,这篇文章都将为你提供一条清晰的学习路径。【8月更文挑战第31天】
|
18天前
|
Java 数据安全/隐私保护 安全
掌握Struts 2动态方法调用,让你的Web开发如虎添翼,轻松应对复杂业务需求!
【8月更文挑战第31天】在Web应用开发中,Struts 2框架因强大功能和灵活性而广受青睐。其动态方法调用(DMI)特性允许在不修改配置文件的情况下动态调用Action类中的方法,相比传统方法调用(需在`struts.xml`中为每个方法创建单独的`&lt;action&gt;`),DMI简化了配置并提升了灵活性、可维护性和扩展性。本文通过对比DMI与传统方法调用,展示如何利用DMI简化开发流程,并强调了在使用DMI时需注意的安全性和访问控制问题。
11 0
|
25天前
|
存储 前端开发
为 HTML 元素指定 CSS 样式的方式
【8月更文挑战第24天】
46 0