实现一个简单的登录注册页面

时间: 2023-05-16 17:04:35 浏览: 114
好的,这是一个常见的编程问题。您可以使用 HTML、CSS 和 JavaScript 来实现一个简单的登录注册页面。以下是一个示例代码: HTML 代码: ``` <!DOCTYPE html> <html> <head> <title>登录注册页面</title> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <div class="container"> <div class="form-container sign-up-container"> <form action="#"> <h1>创建账户</h1> <input type="text" placeholder="用户名"> <input type="email" placeholder="邮箱"> <input type="password" placeholder="密码"> <button>注册</button> </form> </div> <div class="form-container sign-in-container"> <form action="#"> <h1>登录</h1> <input type="text" placeholder="用户名"> <input type="password" placeholder="密码"> <a href="#">忘记密码?</a> <button>登录</button> </form> </div> <div class="overlay-container"> <div class="overlay"> <div class="overlay-panel overlay-left"> <h1>欢迎回来!</h1> <p>请登录您的账户以继续使用我们的服务。</p> <button class="ghost" id="signIn">登录</button> </div> <div class="overlay-panel overlay-right"> <h1>创建账户</h1> <p>请填写您的个人信息以创建账户。</p> <button class="ghost" id="signUp">注册</button> </div> </div> </div> </div> <script src="script.js"></script> </body> </html> ``` CSS 代码: ``` * { box-sizing: border-box; } body { background-color: #f6f5f7; font-family: 'Open Sans', sans-serif; } .container { background-color: #fff; border-radius: 10px; box-shadow: 0 14px 28px rgba(0,0,0,0.25), 0 10px 10px rgba(0,0,0,0.22); position: relative; overflow: hidden; width: 768px; max-width: 100%; min-height: 480px; } .form-container { position: absolute; top: 0; height: 100%; transition: all 0.6s ease-in-out; } .sign-in-container { left: 0; width: 50%; z-index: 2; } .sign-up-container { left: 0; width: 50%; opacity: 0; z-index: 1; } .overlay-container { position: absolute; top: 0; left: 50%; width: 50%; height: 100%; overflow: hidden; transition: transform 0.6s ease-in-out; z-index: 100; } .overlay { background: #ff416c; background: -webkit-linear-gradient(to right, #ff4b2b, #ff416c); background: linear-gradient(to right, #ff4b2b, #ff416c); background-repeat: no-repeat; background-size: cover; background-position: 0 0; color: #fff; position: relative; left: -100%; height: 100%; width: 200%; transform: translateX(0); transition: transform 0.6s ease-in-out; } .overlay-panel { position: absolute; top: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 0 40px; height: 100%; width: 50%; text-align: center; transform: translateX(0); transition: transform 0.6s ease-in-out; } .overlay-left { transform: translateX(-20%); } .overlay-right { right: 0; transform: translateX(0); } form { background-color: #fff; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 0 50px; height: 100%; text-align: center; } h1 { font-weight: bold; margin-top: 0; } input { background-color: #eee; border: none; padding: 12px 15px; margin: 8px 0; width: 100%; } button { border-radius: 20px; border: none; background-color: #ff416c; color: #fff; font-size: 16px; font-weight: bold; padding: 12px 0; margin: 16px 0; width: 100%; cursor: pointer; } button:hover { background-color: #ff4b2b; } .ghost { background-color: transparent; border-color: #fff; color: #fff; } a { color: #fff; font-size: 14px; text-decoration: none; margin: 15px 0; } .overlay-right button:hover { background-color: #fff; color: #ff416c; } .overlay-left button:hover { background-color: #fff; color: #ff416c; } @media screen and (max-width: 960px) { .container { min-height: 830px; height: auto; } .overlay { width: 100%; left: 0; } .form-container { width: 100%; height: 100%; } .sign-up-container { left: 100%; opacity: 1; } .sign-in-container { left: 0; } .overlay-container { width: 100%; left: 0; transform: translateX(0); } .overlay-left { transform: translateX(0); } .overlay-right { transform: translateX(20%); } } ``` JavaScript 代码: ``` const signUpButton = document.getElementById('signUp'); const signInButton = document.getElementById('signIn'); const container = document.getElementById('container'); signUpButton.addEventListener('click', () => { container.classList.add("right-panel-active"); }); signInButton.addEventListener('click', () => { container.classList.remove("right-panel-active"); }); ``` 这个页面包括一个登录表单和一个注册表单,以及一个切换登录和注册表单的功能。您可以根据需要进行修改和扩展。

相关推荐

最新推荐

recommend-type

Android中使用Kotlin实现一个简单的登录界面

Kotlin 是一种在 Java 虚拟机上运行的静态类型编程语言,被称之为 Android 世界的Swift,由 JetBrains 设计开发并开源。接下来本文通过实例代码给大家讲解Android中使用Kotlin实现一个简单的登录界面,一起看看吧
recommend-type

IDEA实现 springmvc的简单注册登录功能的示例代码

主要介绍了IDEA实现 springmvc的简单注册登录功能,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
recommend-type

Android实现注册登录界面的实例代码

主要介绍了Android实现注册登录界面的实例代码,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
recommend-type

用HTML控件实现注册与登录页面

运用文本框、label、按钮等控件实现简单的用户登录页面,登录按钮旁加上新用户注册按钮,连接到用户注册页面。将固定的用户名(admin)和密码(admin)写入代码中,输入正确则提示用户欢迎登录,并显示欢迎图片;...
recommend-type

zigbee-cluster-library-specification

最新的zigbee-cluster-library-specification说明文档。
recommend-type

管理建模和仿真的文件

管理Boualem Benatallah引用此版本:布阿利姆·贝纳塔拉。管理建模和仿真。约瑟夫-傅立叶大学-格勒诺布尔第一大学,1996年。法语。NNT:电话:00345357HAL ID:电话:00345357https://theses.hal.science/tel-003453572008年12月9日提交HAL是一个多学科的开放存取档案馆,用于存放和传播科学研究论文,无论它们是否被公开。论文可以来自法国或国外的教学和研究机构,也可以来自公共或私人研究中心。L’archive ouverte pluridisciplinaire
recommend-type

【实战演练】MATLAB用遗传算法改进粒子群GA-PSO算法

![MATLAB智能算法合集](https://static.fuxi.netease.com/fuxi-official/web/20221101/83f465753fd49c41536a5640367d4340.jpg) # 2.1 遗传算法的原理和实现 遗传算法(GA)是一种受生物进化过程启发的优化算法。它通过模拟自然选择和遗传机制来搜索最优解。 **2.1.1 遗传算法的编码和解码** 编码是将问题空间中的解表示为二进制字符串或其他数据结构的过程。解码是将编码的解转换为问题空间中的实际解的过程。常见的编码方法包括二进制编码、实数编码和树形编码。 **2.1.2 遗传算法的交叉和
recommend-type

openstack的20种接口有哪些

以下是OpenStack的20种API接口: 1. Identity (Keystone) API 2. Compute (Nova) API 3. Networking (Neutron) API 4. Block Storage (Cinder) API 5. Object Storage (Swift) API 6. Image (Glance) API 7. Telemetry (Ceilometer) API 8. Orchestration (Heat) API 9. Database (Trove) API 10. Bare Metal (Ironic) API 11. DNS
recommend-type

JSBSim Reference Manual

JSBSim参考手册,其中包含JSBSim简介,JSBSim配置文件xml的编写语法,编程手册以及一些应用实例等。其中有部分内容还没有写完,估计有生之年很难看到完整版了,但是内容还是很有参考价值的。
recommend-type

"互动学习:行动中的多样性与论文攻读经历"

多样性她- 事实上SCI NCES你的时间表ECOLEDO C Tora SC和NCESPOUR l’Ingén学习互动,互动学习以行动为中心的强化学习学会互动,互动学习,以行动为中心的强化学习计算机科学博士论文于2021年9月28日在Villeneuve d'Asq公开支持马修·瑟林评审团主席法布里斯·勒菲弗尔阿维尼翁大学教授论文指导奥利维尔·皮耶昆谷歌研究教授:智囊团论文联合主任菲利普·普雷教授,大学。里尔/CRISTAL/因里亚报告员奥利维耶·西格德索邦大学报告员卢多维奇·德诺耶教授,Facebook /索邦大学审查员越南圣迈IMT Atlantic高级讲师邀请弗洛里安·斯特鲁布博士,Deepmind对于那些及时看到自己错误的人...3谢谢你首先,我要感谢我的两位博士生导师Olivier和Philippe。奥利维尔,"站在巨人的肩膀上"这句话对你来说完全有意义了。从科学上讲,你知道在这篇论文的(许多)错误中,你是我可以依