jquery实现弹出登录层
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script src="jquery-1.7.2.min.js" type="text/javascript" ></script>
<style type="text/css">
#login{width:300px;height:200px;border:1px solid #ccc;position:relative;}
#close{position:absolute;top:0;right:0;}
</style>
<script>
$(function(){
$('#input1').click(function(){
var oLogin=$('<div id="login"><p>用户名:<input type="text" name="user"/></p><p>密码:<input type="password" name="user"/></p><a href="javascript:" id="close" style="float:right;">x</a></div>');
$('body').append(oLogin);
oLogin.css('left',($(window).width()-oLogin.outerWidth())/2);
oLogin.css('top',($(window).height()-oLogin.outerHeight())/2);
$('#close').click(function(){
oLogin.remove();
});
$(window).on('resize scroll',function(){
oLogin.css('left',($(window).width()-oLogin.outerWidth())/2);
oLogin.css('top',($(window).height()-oLogin.outerHeight())/2+$(window).scrollTop());
});
});
});
</script>
</head>
<body style="height:2000px;">
<input type="button" id="input1" value="创建"/>
</body>
</html>