web全栈开发之网站开发二(弹出式登录注册框前端实现-类腾讯)
这次给大家分享的是目前很多网站中流行的弹出式登录框,如下面的腾讯网登录界面,采用弹出式登录的好处是大大提升了网站的用户体验和交互性,用户不用重新跳转到指定的页面就能登录,非常方便
先来个演示地址

要实现这个功能的大致思路是:
1.首先要在页面上设置一个登录按钮,可以是<button><a><img>都行,我们点击这个元素的时候会弹出登录框

2.其次在页面合适位置制作两个<div>,一个登录功能的div,另一个注册功能的div,注意位置的设置,当网站首次加载进入的时候登录框不可见,那就要把样式设置为display:"none"
3.当用户点击登录按钮的时候,通过JS设置登录div的display="",如何用户点击了登录界面上的注册按钮时,通过jQuery切换div透明和大小就可以完美实现登录注册的切换

4.关闭登录框的话也是同样的道理,把两个div的display设置为none就行
上代码:
sign.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>sign</title>
<style>
body {
text-align: center;
background-color: burlywood;
}
.signform {
font-family: 微软雅黑;
position: fixed;
background-color: white;
top: 20%;
left: 30%;
width: 500px;
height: 400px;
border-radius: 1em;
text-align: center;
z-index: 999;
}
#registerform {
height: 450px;
}
.signclose {
cursor: pointer;
float: right;
overflow: hidden;
text-align: center;
position: relative;
height: 35px;
width: 35px;
margin-top: 10px;
margin-right: 10px;
}
#registerloading{
position: absolute;
width: 25px;
height: 25px;
left: 410px;
top: 90px;
}
.signinput {
text-align: center;
border-radius: 0.2em;
width: 280px;
height: 45px;
border: none;
background-color:#f2f2f2;
font-size: 28px;
}
.signinput::-webkit-input-placeholder {
font-size: 26px;
}
.userdiv {
position: relative;
margin-top: 80px;
}
.pwddiv {
position: relative;
margin-top: 20px;
}
.postdiv {
position: relative;
margin-top: 20px;
}
.postdiv button {
cursor: pointer;
color: white;
font-size: 26px;
border: none;
border-radius: 0.4em;
width: 280px;
height: 45px;
background-color:#4CAF50;
}
</style>
<link rel="stylesheet" href="css/sign.css">
</head>
<body>
<div>
<button id="displaysign" onclick="start()">点击登录</button>
</div>
<div class="signform" id="signform" style="display: none">
<div class="signclose">
<img src="data:image/signclose.ico" width="35px" height="35px" onclick="signclose()">
</div>
<div class="userdiv">
<input id="user" class="signinput" type="text" placeholder="用户名" name="user" >
</div>
<div class="pwddiv">
<input id="pwd" class="signinput" type="password" placeholder="密码" name="pwd">
</div>
<div class="postdiv">
<button>登录</button>
</div>
<br>
<div class="change" style="color: #4d4d4d">
<p>还没有账号?赶快<a href="#" style="text-decoration: none;color: #43A047">注册</a>一个吧</p>
</div>
</div>
<div class="signform" id="registerform" style="display: none">
<div class="signclose">
<img src="data:image/signclose.ico" width="35px" height="35px" onclick="signclose()">
</div>
<div class="userdiv">
<input id="registeruser" class="signinput" onblur="loading()" type="text" placeholder="用户名" name="user">
</div>
<img src="data:image/signloading.gif" style="display: none" id="registerloading">
<div class="pwddiv">
<input id="registerpwd" class="signinput" type="password" placeholder="密码" name="pwd">
</div>
<div class="pwddiv">
<input id="registerrepwd" class="signinput" type="password" placeholder="再次输入密码" name="pwd">
</div>
<div class="postdiv">
<button>注册</button>
</div>
<br>
<div class="change" style="color: #4d4d4d">
<p>已有账号?立刻去<a href="#" style="text-decoration: none;color: #43A047">登录</a>吧</p>
</div>
</div>
</body>
<script src="js/jquery-3.1.1.min.js"></script>
<script src="js/signformchange.js"></script>
</html>
sign.css
body {
text-align: center;
background-color: burlywood;
}
#displaysign{
position: relative;
top: 80px;
width: 70px;
height: 40px;
}
.signform {
font-family: 微软雅黑;
position: fixed;
background-color: white;
top: 20%;
left: 30%;
width: 500px;
height: 400px;
border-radius: 1em;
text-align: center;
z-index:;
}
#registerform {
height: 450px;
}
.signclose {
cursor: pointer;
float: right;
overflow: hidden;
text-align: center;
position: relative;
height: 35px;
width: 35px;
margin-top: 10px;
margin-right: 10px;
}
#registerloading{
position: absolute;
width: 25px;
height: 25px;
left: 410px;
top: 90px;
}
.signinput {
text-align: center;
border-radius: 0.2em;
width: 280px;
height: 45px;
border: none;
background-color:#f2f2f2;
font-size: 28px;
}
.signinput::-webkit-input-placeholder {
font-size: 26px;
}
.userdiv {
position: relative;
margin-top: 80px;
}
.pwddiv {
position: relative;
margin-top: 20px;
}
.postdiv {
position: relative;
margin-top: 20px;
}
.postdiv button {
cursor: pointer;
color: white;
font-size: 26px;
border: none;
border-radius: 0.4em;
width: 280px;
height: 45px;
background-color:#4CAF50;
}
signformchange.js
$(function ()
{
$('.change a').click(function ()
{
$('.signform').animate({height: 'toggle', opacity: 'toggle'}, 'slow');
});
}) function start() {
document.getElementById('signform').style.display=""
} function signclose() {
document.getElementById('signform').style.display="none"
document.getElementById('registerform').style.display="none"
}
function loading() {
document.getElementById('registerloading').style.display=""
}
web全栈开发之网站开发二(弹出式登录注册框前端实现-类腾讯)的更多相关文章
- web全栈后台权限管理系统(VUE+ElementUi+nodeJs+koa2)
web全栈后台权限管理系统(VUE+ElementUi+nodeJs+koa2) 主要技术 前端 vue 全家桶 ElementUI 后端 Node.js Koa2 Mongoess 数据库 mong ...
- 处女作《Web全栈开发进阶之路》出版了!
书中源码下载地址:https://github.com/qinggee/WebAdvanced 01. 当初决定写博客的原因非常的纯洁:只要每个月写上 4 篇以上博客,月底的绩效奖金就多 500 块. ...
- Web 全栈开发 MySQL 面试题
Web 全栈开发 MySQL 面试题 MySQL MySQL 读写分离 读写分离原理 MySQL的主从复制和MySQL的读写分离两者有着紧密联系,首先部署主从复制,只有主从复制完了,才能在此基础上进行 ...
- Web 全栈开发 Redis 面试题
Web 全栈开发 Redis 面试题 Redis 大 key 问题 https://www.cnblogs.com/xgqfrms/p/13601959.html Redis 数据结构 Redis 初 ...
- 从 rails 窥探 web 全栈开发(零)
从 rails 窥探 web 全栈开发(零) 本文将讲述在学习之前几个必须要知道的概念,这些词汇在 rails 中都会出现. 本文前置条件:安装好 Ruby. 从 rails 窥探 web 全栈开发( ...
- 使用IntelliJ IDEA开发SpringMVC网站(二)框架配置
原文:使用IntelliJ IDEA开发SpringMVC网站(二)框架配置 摘要 讲解如何配置SpringMVC框架xml,以及如何在Tomcat中运行 目录[-] 文章已针对IDEA 15做了一定 ...
- Web 全栈大会:万维网之父的数据主权革命
大家好,今天我和大家分享一下由万维网之父发起的一场数据主权革命.什么叫数据主权?很容易理解,现在我们的数据是把持在巨头手里的,你的微信通讯录和聊天记录都无法导出,不管是从人权角度还是从法理角度,这些数 ...
- 基于LeanCloud云引擎的Web全栈方案
LeanEngine-Full-Stack The FULL STACK DEVELOPER 复杂的项目, 协作分工, 自动化流程,代码组织结构,框架选择,国际化方案等 Generator 或者See ...
- 《web全栈工程师的自我修养》阅读笔记
在买之前以为这本书是教你怎么去做一个web全栈工程师,以及介绍需要掌握的哪些技术的书,然而看的过程中才发现,是一本方法论的书.读起来的感觉有点像红衣教主的<我的互联网方法论>,以一些自己的 ...
随机推荐
- 继电器是如何成为CPU的(1)
继电器是如何成为CPU的(1) ——<穿越计算机的迷雾>整理和总结 究竟是如何设计的电路,具有计算和控制的智力? 这一点也不高深.本系列文章从初中学的最简单的电路图说起,看看能不能从最初的 ...
- Sublime Text3配置在可交互环境下运行python快捷键
安装插件 在Sublime Text3下面写代码感觉很不错,但是写Python的时候遇到了一些问题. 用Sublime Text3打开python文件,或者在Sublime Text3下写好pytho ...
- 移动端IOS点击事件失效解决方案
解决方案 解决办法有 4 种可供选择: 1 将 click 事件直接绑定到目标元素(即 .target)上 2 将目标元素换成 <a> 或者 button 等可点击的元素 3 将 clic ...
- 前端学HTTP之Web主机托管
前面的话 对内容资源的存储.协调以及管理的职责统称为Web主机托管.主机托管是Web服务器的主要功能之一.保存并提供内容,记录对内容的访问以及管理内容都离不开服务器.如果不想自行管理服务器所需的软硬件 ...
- Android数据存储之Android 6.0运行时权限下文件存储的思考
前言: 在我们做App开发的过程中基本上都会用到文件存储,所以文件存储对于我们来说是相当熟悉了,不过自从Android 6.0发布之后,基于运行时权限机制访问外置sdcard是需要动态申请权限,所以以 ...
- 解决vs创建或打开C++浏览数据库文件*.sdf时发生错误的问题
VS2012, 创建或打开C++浏览数据库文件*.sdf时发生错误. IntelliSense 和浏览信息将不能用于C++项目. 请确保已安装 Microsoft SQL Server Compac ...
- C#中5步完成word文档打印的方法
在日常工作中,我们可能常常需要打印各种文件资料,比如word文档.对于编程员,应用程序中文档的打印是一项非常重要的功能,也一直是一个非常复杂的工作.特别是提到Web打印,这的确会很棘手.一般如果要想选 ...
- Asp.Net 操作XML文件的增删改查 利用GridView
不废话,直接上如何利用Asp.NET操作XML文件,并对其属性进行修改,刚开始的时候,是打算使用JS来控制生成XML文件的,但是最后却是无法创建文件,读取文件则没有使用了 index.aspx 文件 ...
- c# Enumerable中Aggregate和Join的使用
参考页面: http://www.yuanjiaocheng.net/ASPNET-CORE/asp.net-core-environment.html http://www.yuanjiaochen ...
- ActionContext.getContext().getSession()
ActionContext.getContext().getSession() 获取的是session,然后用put存入相应的值,只要在session有效状态下,这个值一直可用 ActionConte ...