HTML+CSS助你轻松打造惊艳登录页,零基础也能学会!

简介: HTML+CSS助你轻松打造惊艳登录页,零基础也能学会!

效果




完整代码

HTML部分


<div class="login-container" id="loginContainer">
        <h2 class="login-title">创新登录系统</h2>
        <form id="loginForm">
            <div class="form-group">
                <input type="text" id="username" name="username" placeholder="用户名" required>
            </div>
            <div class="form-group">
                <input type="password" id="password" name="password" placeholder="密码" required>
            </div>
            <button type="submit" class="login-button">登录</button>
        </form>
        <div class="forgot-password">
            <a href="#">忘记密码?</a>
        </div>
    </div>

CSS部分


* {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        body, html {
            height: 100%;
            font-family: 'Arial', sans-serif;
            background: linear-gradient(45deg, #b21f1f, #fdbb2d);
            background-size: 400% 400%;
            animation: gradientBG 15s ease infinite;
           
            overflow: hidden;
        }
        @keyframes gradientBG {
            0% {background-position: 0% 50%;}
            50% {background-position: 100% 50%;}
            100% {background-position: 0% 50%;}
        }
        .login-container {
            background: rgba(255, 255, 255, 0.1);
            backdrop-filter: blur(10px);
            border-radius: 20px;
            padding: 40px;
            width: 100%;
            max-width: 400px;
            margin: 100px auto;
            box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
            border: 1px solid rgba(255, 255, 255, 0.18);
            transform: perspective(1000px) rotateY(0deg);
            transition: transform 0.6s ease-out;
        }
        .login-container:hover {
            transform: perspective(1000px) rotateY(-5deg);
        }
        .login-title {
            text-align: center;
            margin-bottom: 30px;
            color: #fff;
            font-size: 28px;
            text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
        }
        .form-group {
            margin-bottom: 20px;
            position: relative;
        }
        .form-group input {
            width: 100%;
            padding: 10px;
            background: rgba(255, 255, 255, 0.2);
            border: none;
            border-radius: 50px;
            color: #fff;
            font-size: 16px;
            transition: all 0.3s ease;
        }
        .form-group input::placeholder {
            color: rgba(255, 255, 255, 0.7);
        }
        .form-group input:focus {
            outline: none;
            background: rgba(255, 255, 255, 0.3);
            box-shadow: 0 0 15px rgba(255, 255, 255, 0.5);
        }
        .login-button {
            width: 100%;
            padding: 12px;
            background: linear-gradient(45deg, #FF512F, #DD2476);
            color: #fff;
            border: none;
            border-radius: 50px;
            font-size: 18px;
            cursor: pointer;
            transition: all 0.3s ease;
            position: relative;
            overflow: hidden;
        }
        .login-button:hover {
            transform: translateY(-3px);
            box-shadow: 0 5px 15px rgba(0,0,0,0.3);
        }
        .login-button:active {
            transform: translateY(0);
            box-shadow: 0 2px 5px rgba(0,0,0,0.3);
        }
        .login-button::after {
            content: '';
            position: absolute;
            top: 50%;
            left: 50%;
            width: 5px;
            height: 5px;
            background: rgba(255, 255, 255, 0.5);
            opacity: 0;
            border-radius: 100%;
            transform: scale(1, 1) translate(-50%);
            transform-origin: 50% 50%;
        }
        @keyframes ripple {
            0% {
                transform: scale(0, 0);
                opacity: 1;
            }
            20% {
                transform: scale(25, 25);
                opacity: 1;
            }
            100% {
                transform: scale(50, 50);
                opacity: 0;
            }
        }
        .login-button:focus:not(:active)::after {
            animation: ripple 1s ease-out;
        }
        .forgot-password {
            text-align: center;
            margin-top: 20px;
        }
        .forgot-password a {
            color: #fff;
            text-decoration: none;
            font-size: 14px;
            transition: all 0.3s ease;
        }
        .forgot-password a:hover {
            text-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
        }
        @keyframes float {
            0% {transform: translateY(0px);}
            50% {transform: translateY(-20px);}
            100% {transform: translateY(0px);}
        }
        .floating-icon {
            position: absolute;
            font-size: 40px;
            opacity: 0.2;
            pointer-events: none;
            animation: float 6s ease-in-out infinite;
        }
    </style>

Js

function createFloatingIcon(emoji) {
            const icon = document.createElement('div');
            icon.className = 'floating-icon';
            icon.style.left = Math.random() * window.innerWidth + 'px';
            icon.style.top = Math.random() * window.innerHeight + 'px';
            icon.style.animationDelay = Math.random() * 5 + 's';
            icon.textContent = emoji;
            document.body.appendChild(icon);
        }
        const emojis = ['🚀', '💻', '📊', '🔐', '📈'];
        emojis.forEach(createFloatingIcon);
        document.getElementById('loginForm').addEventListener('submit', function(e) {
            e.preventDefault();
            const button = this.querySelector('.login-button');
            button.style.animation = 'none';
            button.offsetHeight; // Trigger reflow
            button.style.animation = null;
            // 在这里添加登录逻辑
        });
        document.getElementById('loginContainer').addEventListener('mousemove', function(e) {
            const { left, top, width, height } = this.getBoundingClientRect();
            const x = (e.clientX - left) / width;
            const y = (e.clientY - top) / height;
            
            this.style.transform = `
                perspective(1000px)
                rotateY(${(x - 0.5) * 10}deg)
                rotateX(${(y - 0.5) * -10}deg)
            `;
        });
        document.getElementById('loginContainer').addEventListener('mouseleave', function() {
            this.style.transform = 'perspective(1000px) rotateY(0deg) rotateX(0deg)';
        });
相关文章
|
23天前
|
前端开发
HTML+CSS实现奇特的的企业官网效果
HTML+CSS实现奇特的的企业官网效果
HTML+CSS实现奇特的的企业官网效果
|
4天前
|
Web App开发 前端开发 JavaScript
HTML/CSS/JS学习笔记 Day3(HTML--网页标签 下)
HTML/CSS/JS学习笔记 Day3(HTML--网页标签 下)
|
1天前
|
XML JavaScript 前端开发
JavaWeb基础4——HTML,JavaScript&CSS
HTML,JavaScript&CSS、元素、标签、css 选择器、属性、JavaScript基础语法、JavaScript对象、BOM浏览器对象模型、DOM文档对象模型、事件监听、正则对象RegExp/ES6
JavaWeb基础4——HTML,JavaScript&CSS
|
14天前
|
移动开发 JavaScript 前端开发
揭秘!如何用Web2py+HTML5/CSS3/jQuery打造超炫响应式网站?你的设计梦想即将照进现实!
【8月更文挑战第31天】本文详细介绍如何利用Web2py框架及HTML5、CSS3与jQuery构建响应式网站。首先需安装Python和Web2py,并启动服务器。接着,在Web2py中创建新应用,例如命名为“ResponsiveSite”。随后,编写HTML5基本结构,包括头部、导航栏等元素。在`styles.css`文件中添加CSS3样式代码,实现响应式布局。最后,通过在`scripts.js`中加入jQuery脚本提升页面交互性,如点击导航项时平滑滚动至目标区域。此教程为你打下响应式网站设计的基础,便于进一步扩展和优化。
10 1
|
17天前
|
移动开发 前端开发 JavaScript
HTML与CSS二三事
HTML与CSS二三事
|
23天前
|
前端开发 JavaScript
3分钟掌握!用HTML+CSS实现懒加载,真的这么简单?
3分钟掌握!用HTML+CSS实现懒加载,真的这么简单?
|
23天前
|
前端开发 JavaScript
HTML+CSS实现超酷炫的返回顶部特效,你一定会爱上!
HTML+CSS实现超酷炫的返回顶部特效,你一定会爱上!
|
23天前
|
前端开发 JavaScript
HTML+CSS新技能:快速打造响应式步骤条,秒变网页设计达人!
HTML+CSS新技能:快速打造响应式步骤条,秒变网页设计达人!
|
23天前
|
前端开发 JavaScript
HTML+CSS如何打造撒花动画效果?3分钟学会,炫酷到爆!
HTML+CSS如何打造撒花动画效果?3分钟学会,炫酷到爆!
|
23天前
|
前端开发
HTML+CSS 速成10分钟!一键实现你的后台管理系统首页梦想!
HTML+CSS 速成10分钟!一键实现你的后台管理系统首页梦想!