今天在做小组项目的时候发现登录和注册的使用不是很熟,记录下来:

<script>
//弹出框中的css部分
input { font-family: Arial, sans-serif;}
.login { width: 270px; margin: 0 auto; padding: 30px 40px; background-color: #f7f7f7;}
.login ul { list-style-type: none;}
.login li { padding: 10px 0; overflow: hidden;}
.login .li3, .login .li5 { text-align: right; font-size: 12px;}
.login .li3 input { width: 13px; height: 13px; margin: 0 3px 0 10px; vertical-align: middle;}
.login .submit { display: block; width: 100%; padding: 6px 0; border: 0 none; color: #fff; background-color: #4d90fe; cursor: pointer;}
#email, #password { width: 214px; padding: 5px; border: 1px solid #ccc;}
.forgot { color: #333;}
//遮罩层css部分
#mask {
background: #000000;
opacity: 0.75;
/*IE不认这个属性*/
filter: alpha(opacity=75);
/*这个是为了保证IE兼容*/
height: 800px;
width: 100%;
position: absolute;
z-index: 999;
left: 0;
top: 0;
} #login {
position: fixed;
/*静止定位*/
/*left: 30%;
top: 30%;*/
z-index: 1000;
} .loginCon {
width:350px;
height: 270px;
} //弹出框中的关闭部分 #close {
width: 20px;
height: 20px;
position: absolute;
right: 10px;
top: 10px;
cursor: pointer;
/*border:1px solid red;*/
font-size:24px;
font-weight:400
} </style>
<body> <div id="zd"> <div class="zd1" onclick="openNew()" >登录</div>
<div class="zd1" onclick="show()" >注册</div> </div>
</body> <script type="text/javascript">
function openNew() {
// 获取页面高度和宽度
var sHeight = document.documentElement.scrollHeight;
var sWidth = document.documentElement.scrollWidth;
// alert(sHeight);
// alert(sWidth);
// 可视区域的高度和宽度
var wHeight = document.documentElement.clientHeight;
var wWidth = document.documentElement.clientWidth;
// alert(sHeight);
// alert(sWidth);
var oMask = document.createElement("div");
oMask.id = "mask";
oMask.style.height = sHeight + "px";
oMask.style.width = sWidth + "px";
document.body.appendChild(oMask); var oLogin = document.createElement("div");
oLogin.id = "login";
oLogin.innerHTML = '<div class="loginCon"><div class="loginCon"><div class="login"><ul><li><span><label for="email">邮箱:</label></span><input id="email" type="text"></li><li><span><label for="password">密码:</label></span><input id="password" type="password"></li><li class="li3"><input type="checkbox" id="remember"><label for="remember">记住密码</label> <input type="checkbox" id="togglePassword"><label for="togglePassword">显示密码</label></li><li class="li4"><input class="submit" type="submit" value="登录"></li></ul></div></div><div id="close">×</div></div>';
document.body.appendChild(oLogin);
var dHeight = oLogin.offsetHeight;
var dWidth = oLogin.offsetWidth; oLogin.style.top = (wHeight - dHeight) / 2 + "px";
oLogin.style.left = (wWidth - dWidth) / 2 + "px";
var oClose = document.getElementById("close")
oClose.onclick = function() {
document.body.removeChild(oMask);
document.body.removeChild(oLogin);
}
oMask.onclick = function() {
document.body.removeChild(oMask);
document.body.removeChild(oLogin);
}
}
function show()
{ // 获取页面高度和宽度
var sHeight = document.documentElement.scrollHeight;
var sWidth = document.documentElement.scrollWidth;
// alert(sHeight);
// alert(sWidth);
// 可视区域的高度和宽度
var wHeight = document.documentElement.clientHeight;
var wWidth = document.documentElement.clientWidth;
// alert(sHeight);
// alert(sWidth);
var oMask = document.createElement("div");
oMask.id = "mask";
oMask.style.height = sHeight + "px";
oMask.style.width = sWidth + "px";
document.body.appendChild(oMask); var oLogin = document.createElement("div");
oLogin.id = "login";
oLogin.innerHTML = '<div class="loginCon"><div class="loginCon"><div class="login"><ul><li><span><label for="zhanghao">账号:&nbsp;&nbsp;&nbsp;</label></span><input id="zhanghao " type="text" style="height:23px"></li><li><span><label for="yonghuming">用户名:</label></span><input id="yonghuming" type="text" style="height:23px"></li> <li><span><label for="password">密码:</label></span><input id="password" type="password"></li><li><span><label for="password">确认密码:</label></span><input id="password" type="password"></li><li class="li4"><input class="submit" type="submit" value="提交"></li></ul></div></div><div id="close">×<div></div>'; document.body.appendChild(oLogin);
var dHeight = oLogin.offsetHeight;
var dWidth = oLogin.offsetWidth; oLogin.style.top = (wHeight - dHeight) / 2 + "px";
oLogin.style.left = (wWidth - dWidth) / 2 + "px"; document.getElementById("close").onclick = function() {
document.body.removeChild(oMask);
document.body.removeChild(oLogin);
}
document.getElementById("login").onclick = function() {
document.body.removeChild(oMask);
document.body.removeChild(oLogin);
} }
</script>

最新文章

  1. Linux知识:/root/.bashrc与/etc/profile的异同
  2. [转+原]chrony
  3. Android Launcher分析和修改9——Launcher启动APP流程
  4. Spring+MyBatis实践—工程配置
  5. Apache、Tomcat、JBoss、WebLogic的区别与关系
  6. ExtJs4 笔记(11) Ext.ListView、Ext.view.View 数据视图
  7. 模板引擎mustache.js
  8. Echars 6大公共组件详解
  9. HTML中的表单
  10. 寻找符合条件的最短子字符串——SLIDING WINDOW
  11. Hadoop Shell命令(基于linux操作系统上传下载文件到hdfs文件系统基本命令学习)
  12. 牛客OI周赛7-普及组
  13. 清明 DAY2
  14. C语言程序设计I—第十三周教学
  15. Tomcat权威指南-读书摘要系列6
  16. (GoRails )使用Vue.js制作拖拉list功能(v1-4) gem &#39;acts_as_list&#39;(自动排列顺序)
  17. (C/C++学习笔记) 九. 变量的存储类型
  18. JAVA对象的初始化过程
  19. vs code上配置Scala
  20. 关于android:windowNoTitle不起作用的解决办法

热门文章

  1. 【POJ3498】March of the Penguins(最大流,裂点)
  2. Struts学习总结(一)
  3. hdu 5438(类似拓扑排序)
  4. js-触屏滑动判断滑动方向(移动版)
  5. [功能集锦] 001 - java下载文件
  6. Ubuntu 16.04安装字体管理工具
  7. php 打印今天,昨天,本周,上周,当月,上月,本季,上季,今年,去年数据
  8. 我是如何通过CSRF拿到Shell的
  9. php 的$_POST 和$_REQUEST的区别
  10. C# 解析迅雷链接成正常的Http链接