web全栈开发之网站开发二(弹出式登录注册框前端实现-类腾讯)

这次给大家分享的是目前很多网站中流行的弹出式登录框,如下面的腾讯网登录界面,采用弹出式登录的好处是大大提升了网站的用户体验和交互性,用户不用重新跳转到指定的页面就能登录,非常方便

先来个演示地址

要实现这个功能的大致思路是:

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

2.其次在页面合适位置制作两个<div>,一个登录功能的div,另一个注册功能的div,注意位置的设置,当网站首次加载进入的时候登录框不可见,那就要把样式设置为display:"none"

3.当用户点击登录按钮的时候,通过JS设置登录div的display="",如何用户点击了登录界面上的注册按钮时,通过jQuery切换div透明和大小就可以完美实现登录注册的切换

4.关闭登录框的话也是同样的道理,把两个div的display设置为none就行

上代码:

sign.html

  1 <!DOCTYPE html>
  2 <html lang="en">
  3 <head>
  4     <meta charset="UTF-8">
  5     <title>sign</title>
  6     <style>
  7         body {
  8             text-align: center;
  9             background-color: burlywood;
 10         }
 11         .signform {
 12             font-family: 微软雅黑;
 13             position: fixed;
 14             background-color: white;
 15             top: 20%;
 16             left: 30%;
 17             width: 500px;
 18             height: 400px;
 19             border-radius: 1em;
 20             text-align: center;
 21             z-index: 999;
 22         }
 23         #registerform {
 24             height: 450px;
 25         }
 26         .signclose {
 27             cursor: pointer;
 28             float: right;
 29             overflow: hidden;
 30             text-align: center;
 31             position: relative;
 32             height: 35px;
 33             width: 35px;
 34             margin-top: 10px;
 35             margin-right: 10px;
 36         }
 37         #registerloading{
 38             position: absolute;
 39             width: 25px;
 40             height: 25px;
 41             left: 410px;
 42             top: 90px;
 43         }
 44         .signinput {
 45             text-align: center;
 46             border-radius: 0.2em;
 47             width: 280px;
 48             height: 45px;
 49             border: none;
 50             background-color:#f2f2f2;
 51             font-size: 28px;
 52         }
 53         .signinput::-webkit-input-placeholder {
 54             font-size: 26px;
 55         }
 56         .userdiv {
 57             position: relative;
 58             margin-top: 80px;
 59         }
 60         .pwddiv {
 61             position: relative;
 62             margin-top: 20px;
 63         }
 64         .postdiv {
 65             position: relative;
 66             margin-top: 20px;
 67         }
 68         .postdiv button {
 69             cursor: pointer;
 70             color: white;
 71             font-size: 26px;
 72             border: none;
 73             border-radius: 0.4em;
 74             width: 280px;
 75             height: 45px;
 76             background-color:#4CAF50;
 77         }
 78     </style>
 79     <link rel="stylesheet" href="css/sign.css">
 80 </head>
 81 <body>
 82 <div>
 83     <button id="displaysign" onclick="start()">点击登录</button>
 84 </div>
 85 <div class="signform" id="signform" style="display: none">
 86     <div class="signclose">
 87         <img src="image/signclose.ico" width="35px" height="35px" onclick="signclose()">
 88     </div>
 89     <div class="userdiv">
 90     <input id="user" class="signinput" type="text" placeholder="用户名" name="user" >
 91     </div>
 92     <div class="pwddiv">
 93     <input id="pwd" class="signinput" type="password" placeholder="密码" name="pwd">
 94     </div>
 95     <div class="postdiv">
 96     <button>登录</button>
 97     </div>
 98     <br>
 99     <div class="change" style="color: #4d4d4d">
100         <p>还没有账号?赶快<a href="#" style="text-decoration: none;color: #43A047">注册</a>一个吧</p>
101     </div>
102 </div>
103 <div class="signform" id="registerform" style="display: none">
104         <div class="signclose">
105             <img src="image/signclose.ico" width="35px" height="35px" onclick="signclose()">
106         </div>
107         <div class="userdiv">
108             <input  id="registeruser" class="signinput" onblur="loading()" type="text" placeholder="用户名" name="user">
109         </div>
110     <img src="image/signloading.gif" style="display: none" id="registerloading">
111         <div class="pwddiv">
112             <input  id="registerpwd" class="signinput" type="password" placeholder="密码" name="pwd">
113         </div>
114         <div class="pwddiv">
115             <input  id="registerrepwd" class="signinput" type="password" placeholder="再次输入密码" name="pwd">
116         </div>
117         <div class="postdiv">
118             <button>注册</button>
119         </div>
120         <br>
121         <div class="change" style="color: #4d4d4d">
122             <p>已有账号?立刻去<a href="#" style="text-decoration: none;color: #43A047">登录</a></p>
123         </div>
124 </div>
125 </body>
126 <script src="js/jquery-3.1.1.min.js"></script>
127 <script src="js/signformchange.js"></script>
128 </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: 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;
}

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=""
}

 

转载于:https://www.cnblogs.com/liujianhuaIT/p/6256261.html

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
1,实现的需求 1)首页:标题栏获取用户当前位置,使用腾讯api实现定位,不用弹窗出现用户授权, 进入首页,获取附近商铺的列表 轮播图: 导航栏: (1)向后台发送请求来获取展示的商铺列表,综合排序,筛选实现根据用户 条件请求数据 (2)导航栏出现偏移 商铺列表: (1)带参跳转店铺 网络中断情况: 新页面提示没网,可点击刷新 2)店铺:根据店铺id获取店铺相关信息 头部:动态显示店铺的相关优惠 导航:分别切换菜单,评价,商家 菜单: 商品列表展示:左右联动,动态出现添加数量以及按钮 商品详情展示:弹窗卡片,展示详情,可动态出现添加数量以及按钮 购物车:展示添加进购物车的商品信息,清空结算,计算合价,差多少配送, 结算:(未实现),跳转支付,传后台购物车数据,用户信息,当前时间等订单 需求信息 评价:根据店铺id获取店铺的所有评价list展示 商家:展示商家优惠信息,需求(呼叫商家,查看食品安全档案) 3)订单 全部订单:根据用户信息获取相关全部订单,实现详情,再来一点(需要根据店铺 id) 待评价:需求:实现评价功能(提交:店铺id,评价信息) 退款:评价,详情 4)个人 用户信息展示: 登录: 未登录:(登录,注册实现) 用户地址: 管理地址:添加新地址,编辑地址(地址id,用户id) 客服中心:接入客服(公众号后台可设置客服人员) 退出账号:清空本地用户信息

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值