用Tab选项菜单实现登录注册界面要求只用HTML和css实现

时间: 2023-11-28 22:49:15 浏览: 34
好的,以下是一个简单的登录注册界面的HTML和CSS实现示例: ```html <!DOCTYPE html> <html> <head> <title>Login/Register Form</title> <style> body { font-family: Arial, sans-serif; background-color: #f2f2f2; } form { background-color: #fff; border-radius: 5px; padding: 20px; width: 300px; margin: 50px auto; box-shadow: 0 0 10px rgba(0, 0, 0, 0.3); } h2 { text-align: center; margin-top: 0; } input[type="text"], input[type="password"] { display: block; width: 100%; padding: 10px; margin-bottom: 20px; border: none; border-radius: 5px; box-shadow: 0 0 5px rgba(0, 0, 0, 0.1); } input[type="submit"] { background-color: #4caf50; color: #fff; padding: 10px; border: none; border-radius: 5px; cursor: pointer; } input[type="submit"]:hover { background-color: #3e8e41; } .tab { overflow: hidden; border: 1px solid #ccc; background-color: #f1f1f1; border-radius: 5px; } .tab button { background-color: inherit; float: left; border: none; outline: none; cursor: pointer; padding: 14px 16px; transition: 0.3s; font-size: 17px; border-radius: 5px 5px 0 0; } .tab button.active { background-color: #ccc; } .tabcontent { display: none; padding: 6px 12px; border: 1px solid #ccc; border-top: none; border-radius: 0 5px 5px 5px; } .tabcontent.active { display: block; } </style> </head> <body> <form> <h2>Login/Register</h2> <div class="tab"> <button class="tablinks active" onclick="openTab(event, 'login')">Login</button> <button class="tablinks" onclick="openTab(event, 'register')">Register</button> </div> <div id="login" class="tabcontent active"> <input type="text" placeholder="Username"> <input type="password" placeholder="Password"> <input type="submit" value="Login"> </div> <div id="register" class="tabcontent"> <input type="text" placeholder="Username"> <input type="password" placeholder="Password"> <input type="password" placeholder="Confirm Password"> <input type="submit" value="Register"> </div> </form> <script> function openTab(evt, tabName) { var i, tabcontent, tablinks; tabcontent = document.getElementsByClassName("tabcontent"); for (i = 0; i < tabcontent.length; i++) { tabcontent[i].classList.remove("active"); } tablinks = document.getElementsByClassName("tablinks"); for (i = 0; i < tablinks.length; i++) { tablinks[i].classList.remove("active"); } document.getElementById(tabName).classList.add("active"); evt.currentTarget.classList.add("active"); } </script> </body> </html> ``` 这个示例代码中,使用了`<div>`元素和CSS的样式来实现选项卡效果,JavaScript函数`openTab()`用于切换选项卡的显示。该示例中同时实现了登录和注册表单,用户可以通过切换选项卡来切换登录和注册表单的显示。

相关推荐

最新推荐

recommend-type

html 实现tab切换的示例代码

tab切换在项目中也算是常用技术,一般实现tab切换都用js或者jq实现,今天介绍两种只用css实现tab切换方法: 方法一: 原理:通过label标签的关联属性和input的单选类型实现相应div的显示 1.创建一个类名为wrap的div...
recommend-type

利用js+css+html实现固定table的列头不动

1、CSS &lt;style type="text/css"&gt; #scroll_head { position: absolute; display: none; } &lt;/style&gt; 2、Javascript [removed] //该函数在上面一个table数据加载完成后调用 //把表头的宽度设置到会...
recommend-type

详解使用vue实现tab 切换操作

主要介绍了详解使用vue实现tab操作,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
recommend-type

基于Vue实现tab栏切换内容不断实时刷新数据功能

在项目开发中遇到这样需求,就是有几个tab栏,每个tab栏对应的ajax请求不一样,内容区域一样,内容为实时刷新数据,实现方法其实很简单的,下面小编给大家带来了基于Vue实现tab栏切换内容不断实时刷新数据功能,需要...
recommend-type

vue 实现用户登录方式的切换功能

主要介绍了vue 实现用户登录方式的切换功能,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
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

实现实时数据湖架构:Kafka与Hive集成

![实现实时数据湖架构:Kafka与Hive集成](https://img-blog.csdnimg.cn/img_convert/10eb2e6972b3b6086286fc64c0b3ee41.jpeg) # 1. 实时数据湖架构概述** 实时数据湖是一种现代数据管理架构,它允许企业以低延迟的方式收集、存储和处理大量数据。与传统数据仓库不同,实时数据湖不依赖于预先定义的模式,而是采用灵活的架构,可以处理各种数据类型和格式。这种架构为企业提供了以下优势: - **实时洞察:**实时数据湖允许企业访问最新的数据,从而做出更明智的决策。 - **数据民主化:**实时数据湖使各种利益相关者都可
recommend-type

解释minorization-maximization (MM) algorithm,并给出matlab代码编写的例子

Minorization-maximization (MM) algorithm是一种常用的优化算法,用于求解非凸问题或含有约束的优化问题。该算法的基本思想是通过构造一个凸下界函数来逼近原问题,然后通过求解凸下界函数的最优解来逼近原问题的最优解。具体步骤如下: 1. 初始化参数 $\theta_0$,设 $k=0$; 2. 构造一个凸下界函数 $Q(\theta|\theta_k)$,使其满足 $Q(\theta_k|\theta_k)=f(\theta_k)$; 3. 求解 $Q(\theta|\theta_k)$ 的最优值 $\theta_{k+1}=\arg\min_\theta Q(
recommend-type

JSBSim Reference Manual

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