第一百三十三节,JavaScript,封装库--弹出登录框
JavaScript,封装库--弹出登录框
封装库,增加了两个方法
yuan_su_ju_zhong()方法,将获取到的区块元素居中到页面,
chuang_kou_shi_jian()方法,浏览器窗口事件,当窗口的大小变化时触发函数
/** yuan_su_ju_zhong()方法,将获取到的区块元素居中到页面,
* 注意:使用此方法时,首先要在css里将目标区块设置成(绝对定位,position: absolute;)
**/
feng_zhuang_ku.prototype.yuan_su_ju_zhong = function () {
if (this.jie_dian.length == 1) {
var yan_su = null;
for (var i = 0; i < this.jie_dian.length; i++) {
yan_su = this.jie_dian[i];
}
var style = window.getComputedStyle ? window.getComputedStyle(yan_su, null) : null || yan_su.currentStyle;
var y_style = style.display;
if (y_style === "none") {
yan_su.style.display = "block";
}
var width = yan_su.offsetWidth;
var height = yan_su.offsetHeight;
if (y_style === "none") {
yan_su.style.display = "none";
}
var top = (document.documentElement.clientHeight - height) / 2;
var left = (document.documentElement.clientWidth - width) / 2;
for (var ii = 0; ii < this.jie_dian.length; ii++) {
this.jie_dian[ii].style.top = top + 'px';
this.jie_dian[ii].style.left = left + 'px';
}
} else {
alert("区块元素页面居中,只能设置一个区块元素,目前jie_dian数组里是多个元素请检查!")
}
return this;
}; /** chuang_kou_shi_jian()方法,浏览器窗口事件,当窗口的大小变化时触发函数
* 接收一个参数,就是触发时要执行的函数(包含函数功能)
**/
feng_zhuang_ku.prototype.chuang_kou_shi_jian = function (fn) {
window.onresize = fn;
return this;
};
弹出登录框

html代码
<div id="login">
<h2><img src="img/close.png" alt="" class="close" />网站登录</h2>
<div class="user">帐 号:<input type="text" name="user" class="text" /></div>
<div class="pass">密 码:<input type="password" name="pass" class="text" /></div>
<div class="button"><input type="button" class="submit" value="" /></div>
<div class="other">注册新用户 | 忘记密码?</div>
</div>
css代码
/*登录框*/
#login{
width: 350px;
height: 250px;
border: 1px solid #ccc;
position:absolute;
display: none;
}
#login h2{
background: rgba(0, 0, 0, 0) url("img/login_header.png") repeat-x scroll 0 0;
border-bottom: 1px solid #ccc;
color: #666;
font-size: 14px;
height: 40px;
line-height : 40px;
text-align: center;
letter-spacing: 1px;
margin: 0 0 20px;
}
#login h2 img{
cursor: pointer;
float: right;
position: relative;
right: 8px;
top: 14px;
}
#login div.user, #login div.pass {
color: #666;
font-size: 14px;
padding: 5px 0;
text-align: center;
}
#login input.text {
background: #fff none repeat scroll 0 0;
border: 1px solid #ccc;
font-size: 14px;
height: 25px;
width: 200px;
}
#login .button {
padding: 20px 0;
text-align: center;
}
#login input.submit {
background: rgba(0, 0, 0, 0) url("img/login_button.png") no-repeat scroll 0 0;
border: medium none;
cursor: pointer;
height: 30px;
width: 107px;
}
#login .other {
color: #666;
padding: 15px 10px;
text-align: right;
前台js代码
//弹出登录框
//获取登录框,执行将登录框居中方法,执行浏览器窗口事件方法
$().huo_qu_id('login').yuan_su_ju_zhong().chuang_kou_shi_jian(function () {
//获取登录框,执行将登录框居中方法
$().huo_qu_id('login').yuan_su_ju_zhong();
});
//获取登录元素节点,执行点击事件方法
$().huo_qu_class('deng_lu').on_click(function () {
//获取登录框,改变css
$().huo_qu_id('login').css('display','block');
});
//获取登录框里的关闭元素,执行点击事件方法
$().huo_qu_class('close').on_click(function () {
//获取登录框,改变css
$().huo_qu_id('login').css('display','none')
});
第一百三十三节,JavaScript,封装库--弹出登录框的更多相关文章
- 第一百五十三节,封装库--JavaScript,表单验证--备注字数验证
封装库--JavaScript,表单验证--备注字数验证 效果图 html <div id="reg"> <h2 class="tuo"> ...
- 第一百五十节,封装库--JavaScript,表单验证--密码验证
封装库--JavaScript,表单验证--密码验证 效果图 html <div id="reg"> <h2 class="tuo">& ...
- 第一百六十节,封装库--JavaScript,ajax注册表单到数据库
封装库--JavaScript,ajax注册表单到数据库 效果图 前台js var biaodan = $().xu_lie_biao_dan($('form').sh_jd()); //序列化获取表 ...
- 第一百五十八节,封装库--JavaScript,ajax说明
封装库--JavaScript,ajax说明 封装库ajax()方法,ajax通讯方法,跨页面向动态页面发送或获取数据 /** ajax()方法,ajax通讯方法,跨页面向动态页面发送或获取数据 * ...
- 第一百三十五节,JavaScript,封装库--拖拽
JavaScript,封装库--拖拽 封装库新增1个拖拽方法 /** tuo_zhuai()方法,将一个弹窗元素实现拖拽功能 * 注意:一般需要在css文件将元素里的某一个区块光标设置成提示可以拖拽, ...
- 第一百三十四节,JavaScript,封装库--遮罩锁屏
JavaScript,封装库--遮罩锁屏 封装库新增1个方法 /** zhe_zhao_suo_ping()方法,将一个区块元素设置成遮罩锁屏区块 * 注意:一般需要在css文件将元素设置成隐藏 ** ...
- 第三百三十三节,web爬虫讲解2—Scrapy框架爬虫—Scrapy模拟浏览器登录—获取Scrapy框架Cookies
第三百三十三节,web爬虫讲解2—Scrapy框架爬虫—Scrapy模拟浏览器登录 模拟浏览器登录 start_requests()方法,可以返回一个请求给爬虫的起始网站,这个返回的请求相当于star ...
- 【JavaScript 12—应用总结】:弹出登录框
导读:上篇博客中,做好了个人中心的下拉菜单,这次,将做每个网站都会有的一个登录功能,以此类推,可以做出别的想要的弹出框,如错误提示啦,或者注册. 一.实现分析 首先:和下拉菜单一样,需要通过CSS样式 ...
- 第一百三十九节,JavaScript,封装库--CSS选择器
JavaScript,封装库--修改元素选择器 就是将构造库函数修改成元素选择器,像css那样,输入#xxx .xxx xxx (获取指定id下的指定class下的指定标签元素) 修改后的基础库 / ...
随机推荐
- Memcache存储大量数据的问题
Memcache存储大数据的问题 huangguisu Memcached存储单个item最大数据是在1MB内,假设数据超过1M,存取set和get是都是返回false,并且引起性能的问题. 我们之 ...
- 数据结构队列的java实现,包括线性和链式两种方式
实现的思路为: 采用泛型的方式,首先定义了一个Queue的接口,然后通过实现该接口实现了线性和链式的两种形式的队列: 接口代码如下: package com.peter.java.dsa.interf ...
- 大量Javascript/JQuery学习教程电子书合集
[推荐分享]大量Javascript/JQuery学习教程电子书合集,送给有需要的人 不收藏是你的错^_^. 经证实,均可免费下载. 资源名称 资源大小 15天学会jQuery(完整版).pd ...
- 代码阅读软件kscope源码安装指导
安装 kscope-1.6.2 1. ./configure --without-arts --prefix=/soft/kscope-1.6.2 (I customize the installi ...
- TDD中的单元测试
TDD中的单元测试写多少才够? 测试驱动开发(TDD)已经是耳熟能详的名词,既然是测试驱动,那么测试用例代码就要写在开发代码的前面.但是如何写测试用例?写多少测试用例才够?我想大家在实际的操作过程 ...
- MVVM框架avalon在兼容旧式IE
迷你MVVM框架avalon在兼容旧式IE做的努力 当前标签: avalon 共3页: 1 2 3 下一页 迷你MVVM框架avalon在兼容旧式IE做的努力 司徒正美 2014-03-13 11: ...
- 企业架构研究总结(31)——TOGAF架构内容框架之内容元模型(下)
2.2 治理扩展(Governance Extensions) 治理扩展元模型内容 治理扩展部分的意图在于引入额外的,并且与支持运营治理的目标和业务服务相关的结构化数据. 2.2.1 关注范围 为目标 ...
- 调WScript.Shell时报错:Automation 服务器不能创建对象
我们经常需要通过生成ActiveXObject("WScript.Shell");来调某一exe文件, 如 //设置网页打印的页眉页脚为空 var HKEY_Root,HKEY_P ...
- JSP和JavaBean
JSP JSP全称是Java Server Pages.JSP实际上就是Servlet. JSP原理:JSP会被Tomcat翻译成一个Servlet JSP语法 1)JSP的Java脚本表达式 作用: ...
- phpredis扩展
<?php $redis = new Redis(); $redis->connect('127.0.0.1',6379); $redis->set('test','hello wo ...