原生js实现半透明遮罩层效果具体代码
发布时间:2024-07-11 03:02:00
标签:原生js,半透明,遮罩层
<!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>
<style>
* {
margin: 0;
padding: 0;
font-size: 12px;
}
html, body {
height: 100%;
width: 100%;
}
#content {
background: #FFFFFF;
padding: 30px;
height: 100%;
}
#content a {
font-size: 30px;
color: #369;
font-weight: 700;
}
#alert { z-index:2;
border: 1px solid #369;
width: 300px;
height: 150px;
background: #e2ecf5;
z-index: 1000;
position: absolute;
display: none;
}
#alert h4 {
height: 20px;
background: #369;
color: #fff;
padding: 5px 0 0 5px;
}
#alert h4 span {
float: left;
}
#alert h4 span#close {
margin-left: 210px;
font-weight: 500;
cursor: pointer;
}
#alert p {
padding: 12px 0 0 30px;
}
#alert p input {
width: 120px;
margin-left: 20px;
}
#alert p input.myinp {
border: 1px solid #ccc;
height: 16px;
}
#alert p input.sub {
width: 60px;
margin-left: 30px;
}
#mask{ position:absolute; top:0; left:0; height:100%; width:100%; background:#000; opacity:0.3; display:none; z-index:1;}
</style>
</head>
<body>
<div id="content"> <a href="#">注册</a> </div>
<div id="alert">
<h4><span>现在注册</span><span id="close">关闭</span></h4>
<p>
<label> 用户名</label>
<input type="text" class="myinp" onmouseover="this.style.border='1px solid #f60'" onfoucs="this.style.border='1px solid #f60'" onblur="this.style.border='1px solid #ccc'" />
</p>
<p>
<label> 密码</label>
<input type="password" class="myinp" onmouseover="this.style.border='1px solid #f60'" onfoucs="this.style.border='1px solid #f60'" onblur="this.style.border='1px solid #ccc'" />
</p>
<p>
<input type="submit" value="注册" class="sub" />
<input type="reset" value="重置" class="sub" />
</p>
</div>
<div id="mask"></div><!-- 遮罩层div-->
<script type="text/javascript">
var myAlert = document.getElementById("alert");
var myMask=document.getElementById('mask');
var reg = document.getElementById("content").getElementsByTagName("a")[0];
var mClose = document.getElementById("close");
reg.onclick = function()
{
myMask.style.display="block";
myAlert.style.display = "block";
myAlert.style.position = "absolute";
myAlert.style.top = "50%";
myAlert.style.left = "50%";
myAlert.style.marginTop = "-75px";
myAlert.style.marginLeft = "-150px";
document.body.style.overflow = "hidden";
}
mClose.onclick = function()
{
myAlert.style.display = "none";
myMask.style.display = "none";
}
</script>
</body>
</html>


猜你喜欢
- 在用户登录windows操作系统的时候,如果触发到了登录表单的密码录入框上,并且此时按下了“大写锁定键(Caps Lock)”,那么界面上会
- 一、Browser Capabilities组件 该组件最主要的作用是:提取识别客户端浏览器的版本信息。其原理是这样的:当客户端浏览器向服务
- <?php $fp = fopen("http://www.***.com/**
- 文章转自微信公众号-Python之禅众所周知,Python 不是一种执行效率较高的语言。此外在任何语言中,循环都是一种非常消耗时间的操作。假
- #!/usr/bin/env python#coding=utf-8import osfrom pyinotify import Watch
- 在本地安装mysql的服务端,打开cmd,cd到mysql安装目录下的bin目录,bin目录中可以看到多个可执行文件,其中mysqladmi
- 1. 简介Python 读写文件的二进制数据需要使用到struct模块,进行C/C++与Python数据格式的转换。2. struct模块介
- 本文实例讲述了Python实现曲线拟合操作。分享给大家供大家参考,具体如下:这两天学习了用python来拟合曲线。一、环境配置本人比较比较懒
- 本文实例讲述了Python使用正则表达式过滤或替换HTML标签的方法。分享给大家供大家参考,具体如下:python正则表达式关键内容:pyt
- 1、首先安装火狐浏览器有单独文章分享怎么安装2、搭建python环境安装python,安装的时候把path选好,就不用自己在配置,安装方法有
- 列表有自己的sort方法,其对列表进行原址排序,既然是原址排序,那显然元组不可能拥有这种方法,因为元组是不可修改的。排序,数字、字符串按照A
- 环境:OS:Red Hat Enterprise Linux AS release 4 (Nahant)DB:Oracle Database
- 前言虽然各种编程语言之间大部分语法存在共通的地方,但是在一些细节的处理上还是千差万别才接触Python不久(之前是学Java的),实在想吐槽
- python sys模块包含了与python解释器和它的环境有关的函数,这个你可以通过dir(sys)来查看他里面的方法和成员属性impor
- 使用Qt Creator创建默认的窗体程序后,主窗口QMainWindow有statusBar状态栏,在此状态栏实时显示时间可以使用下面方法
- 第一次发博客,还有点小激动,本人现在正在天津上大学,希望以后从事前端这一行业,学习的时间不长,写博客为了记录自己的学习过程和收获,当然也算是
- 在我的前一篇教程《九宫格基本布局》中,我介绍了用相对定位加绝对定位的方法来制作九宫格的基本布局。这是一种比较符合人们惯性思维的方法,好像制作
- 目录安装模块XlsxWriter 示例合并Excel数据表头都一样的 excel表头都不一样的 excel表头都不一样的 excel安装模块
- 一、lower():将大写字母全部转为小写字母。如:name='G'b=name.lower()二、title”"
- 使用数据库的过程中,由于断电或其他原因,有可能导致数据库出现一些小错误,比如检索某些表特别慢,查询不到符合条件的数据等。出现这些情况的原因,