
#实现原理:
将弹窗内容写在一个div里面,设置display属性为none
按钮点击绑定事件,将上述div的display属性改为block
<body>
<p>示例弹出页:
<a href="javascript:void(0)" onclick="document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block'">
请点这里
</a>
</p>
<div id="light" class="white_content">
<div id="font_login">Login in</div>
<!-- 登陆部分代码 -->
<form action="" method="post" id="form_submit">
账号:<input type="text" name="" id="name" value="" /></br>
密码:<input type="password" name="" id="password" value="" /></br>
<input type="button" value="确认" class="button_beautiful ceshi" /> <!-- 不要点击 -->
<input type="button" value="取消" class="button_beautiful" onclick="document.getElementById('light').style.display='none';document.getElementById('fade').style.display='none'" />
</form>
</div>
<div id="fade" class="black_overlay"></div>
</body>
<style type="text/css">
.black_overlay {
display: none;
/* 此元素不会被显示*/
position: absolute;
top: 0%;
left: 0%;
width: 100%;
height: 100%;
/*background-color: #bbbbbb;*/
z-index: 1001;
/* z-index 属性设置元素的堆叠顺序。*/
opacity: .80;
/* opacity 属性设置元素的不透明级别。*/
}
.white_content {
display: none;
position: absolute;
top: 40%;
border: 1px solid #bbbbbb;
border-radius: 20px;
background-color: white;
z-index: 1002;
/*层级要比.black_overlay高,这样才能显示在它前面*/
overflow: auto;
}
#light {
position: fixed;
/*全局悬浮*/
left: 50%;
/* top: 50%; */
width: 300px;
height: 250px;
margin-left: -150px;
/* margin-top: -125px */;
}
#form_submit {
text-align: center;
margin-left: 10px;
margin-top: 10px;
}
#font_login {
font-weight: 400;
font-size: 24px;
color: #BBBBBB;
text-align: center;
margin-top: 20px;
}
.button_beautiful {
width: 115px;
height: 46px;
border-width: 0px;
border-radius: 6px;
background: #0753f5;
cursor: pointer;
outline: none;
color: white;
font-size: 21px;
margin-top: 20px;
font-weight: bold;
padding-right: 20px;
}
</style>
版权声明:若无特殊注明,本文内容为枫墨博客原创,转载请以超链接形式保留文章出处.
如有转载文章时未标明出处或侵犯您的权益或版权,请邮件6314672@qq.com与我们联系删除.
本平台资源仅供个人学习交流,测试使用,请勿用于任何盈利商业用途.
版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑或手机中彻底删除下载内容.