字段div弹出层(垂直与横向居中)兼容ie和ff

div 居中  时间:2021-01-24  阅读:()

下面是整个页面的代码,总共分为CSS和Javascript和HTML三部份复制后运行就可以了里面有个背景图要自己换掉。

#alertdiv{position:absolute;height:450px;width:400px;z-index:9999; left:50%;margin-left:-200px;padding:1 px;border:1 px#ccc sol id; font-size:12px;display:none;background-color:#FFFFFF}

#alertdiv h2{position:relative; height:23px;background-color:#E4E4E4;font-size:12px;padding:0;padding-left:5px; l ine-height:23px;margin:0; }

#alertdiv h2 a{position:absolute;display:block;right:5px; top:3px;display:block;margin:0;width:16px;height:16px;margin:0;padding:0;overflow:hidden;backgrou nd:u rl(images/icon/action_delete.gif) no-repeat;cursor:pointer; text-indent:-999px}

.forminfo{padding:5px;}

. inputR{width:120px;}

.bg{background-color:#CCC;-moz-opacity:0.5; fi lter:alpha(opacity=50);height:10000px;width:120%;position:absolute;z-index:9998; left:0; top:0;display:none}function alertinfo(id){

//显示弹出层var obj=document.getElementById(id);var W=screen.width;//取得屏幕分辨率宽度var H=screen.height;//取得屏幕分辨率高度var yScrol l ;//取滚动条高度if (se lf.p a geYOffs et) {yScrol l=self.pageYOffset;

}else if (document.documentElement&&document.documentElement.scrollTop){yScrol l=document.documentElement.scrol lTop;

}else if (document.body) {yScrol l=document.body.scrollTop;

}

//obj.style.marginL eft=(W/2-200)+"px";obj.style.top=(H/2-90-225 + yScrol l)+"px";document.getElementById("bg").style.display="block";obj.style.display="block";var scrollstyle=scrolls();scrol lstyle.style.overflowX="hidden";scrol lstyle.style.overflowY="hidden";

}function closediv(id){

//关闭弹出层

document.getElementById(id).style.display="none";document.getElementById("bg").style.display="none";var scrollstyle=scrolls();scrol lstyle.style.overflowY="auto";scrol lstyle.style.overflowX="hidden";

}function scrol ls(){

//取浏览器类型var temp_h1 =document.body.cl ientHeight;var temp_h2=document.documentElement.cl ientHeight;var isXhtml=(temp_h2<=temp_h1&&temp_h2!=0)?true:false;var htmlbody=isXhtml?document.documentElement:document.body;return htmlbody;

}

<div class="bg" id="bg"></div>

<div id="alertdiv">

<h2>请填写表单信息<a href="javascript:closediv('alertdiv')" title="关闭">关闭</a></h2><div class="forminfo">

<table width="100%"border="0"al ign="center"cel lpadding="5">

<form id="form1"name="form1"method="post"action="">

<tr>

<td width="21%"al ign="right">字段一 </td>

<td width="41%"><input type="text"name="textfield" id="textfield"class="inputR"/></td><td width="38%">&nbsp;</td>

</tr>

<tr>

<td al ign="right">字段三 </td>

<td><input type="text"name="textfield2" id="textfield2"class="inputR"/></td>

<td>&nbsp;</td>

</tr>

<tr>

<td al ign="right">字段四 </td>

<td><input type="text"name="textfield3" id="textfield3"class="inputR"/></td><td>&nbsp;</td>

</tr>

<tr>

<td al ign="right">字段五 </td>

<td><input type="text"name="textfield4" id="textfield4"class="inputR"/></td><td>&nbsp;</td>

</tr>

<tr>

<td al ign="right">&nbsp;</td>

<td colspan="2"><label><input type="submit"name="button" id="button"value="提交" /></label>

<label><input type="reset"name="button2" id="button2"value="重置" /></label></td></tr>

</fo r m>

</table>

</div>

</div>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>;&nbsp;</p>

<p>&nbsp;</p>

<p><a href="javascript:alertinfo('alertdiv');">显示弹出层</a></p>

[6.18]DogYun:充100送10元,态云7折,经典云8折,独立服务器月省100元,幸运大转盘最高5折

DogYun是一家2019年成立的国人主机商,提供VPS和独立服务器租用等,数据中心包括中国香港、美国洛杉矶、日本、韩国、德国、荷兰等,其中VPS包括常规VPS(经典云)和按小时计费VPS(动态云),使用自行开发的面板和管理系统,支持自定义配置,动态云各个硬件独立按小时计费,带宽按照用户使用量计费(不使用不计费)或者购买流量包,线路也可以自行切换。目前商家发布了6.18促销方案,新购动态云7折,经...

RAKsmart:美国洛杉矶独服,E3处理器/16G/1TB,$76.77/月;美国/香港/日本/韩国站群服务器,自带5+253个IPv4

RAKsmart怎么样?RAKsmart机房即日起开始针对洛杉矶机房的独立服务器进行特别促销活动:低至$76.77/月,最低100Mbps带宽,最高10Gbps带宽,优化线路,不限制流量,具体包括有:常规服务器、站群服务器、10G大带宽服务器、整机机柜托管。活动截止6月30日结束。RAKsmart,美国华人老牌机房,专注于圣何塞服务器,有VPS、独立服务器等。支持PayPal、支付宝付款。点击直达...

PQ.hosting全线9折,1Gbps带宽不限流量VPS/€3/月,全球11大机房可选

Hostadvice主机目录对我们的服务进行了测试,然后给PQ.hosting颁发了十大WordPress托管奖。为此,宣布PQ.Hosting将在一周内进行折扣优惠,购买和续订虚拟服务器使用优惠码:Hostadvice ,全部优惠10%。PQ.hosting,国外商家,成天于2019年,正规公司,是全球互联网注册商协会 RIPE 的成员。主要是因为提供1Gbps带宽、不限流量的基于KVM虚拟的V...

div 居中为你推荐
免费个人网站制作怎样免费制作个人网站?百度空间首页怎样登录百度博客qq空间首页QQ空间主页怎么弄?滚筒洗衣机和波轮洗衣机哪个好波轮洗衣机和滚桶洗衣机哪个好?哪个更实用?滚筒洗衣机和波轮洗衣机哪个好滚筒洗衣机和波轮洗衣机有什么不同迈腾和帕萨特哪个好迈腾和帕萨特哪个好闪迪和金士顿哪个好tf卡闪迪和金士顿哪个更好少儿英语哪个好少儿英语哪套教材好哪里好呢?机械表和石英表哪个好买石英表还是机械表好啊手机管家哪个好最好的手机管家
三级域名网站 sugarhosts 服务器配置技术网 google镜像 荷兰服务器 外国域名 42u标准机柜尺寸 英语简历模板word 国外免费空间 论坛空间 gspeed 静态空间 畅行云 主机返佣 google搜索打不开 脚本大全 香港博客 WHMCS 德国代理ip crontab 更多