css+js实现部分区域高亮可编辑遮罩层
时间:2024-02-25 08:49:23
想大家都做过遮罩层这种常见的功能,css或jquery实现,实现方式多样化,这里http://我介绍我在项目中实现的方式,全屏遮罩,部分区域可操作,非常实用。
效果如下图:
js 实现部分:
<script type="text/javascript">
var myAlert = document.getElementById("alert");
var reg = document.getElementById("content").getElementsByTagName("a")[0];
reg.onclick = function() {
myAlert.style.background = "#e2ecf5";
myAlert.style.zIndex = "501";
myAlert.style.position = "absolute";
var signSpan = document.getElementById("signSpanId");
myAlert.style.top = signSpan.offsetTop;
myAlert.style.left = signSpan.offsetLeft;
mybg = document.createElement("div");
mybg.setAttribute("id", "mybg");
mybg.style.background = "#000";
mybg.style.width = "100%";
mybg.style.height = "100%";
mybg.style.position = "absolute";
mybg.style.top = "0";
mybg.style.left = "0";
mybg.style.zIndex = "500";
mybg.style.opacity = "0.3";
mybg.style.filter = "Alpha(opacity=30)";
document.body.appendChild(mybg);
//document.body.style.overflow = "hidden";
}
</script>
页面代码:
<!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=gb2312" />
</head>
<body>
<table border="1" align="center" width="700px">
<tr>
<td width="300px" height="200px" style="font-size:28px; font-weight:bold">
<div id="content">
<a href="#">
启动遮罩层
</a>
</div>
</td>
<td style="vertical-align:top">
<div id="signSpanId" style="position:absolute;"></div>
<div id="alert" align="top">
<h4>
<span>
这是高亮显示区域
</span>
</h4>
<p>
<label>
用户名
</label>
<input type="text" />
</p>
<p>
<label>
密码
</label>
<input type="password" />
</p>
<p>
<input type="submit" value="注册" />
<input type="reset" value="重置" />
</p>
</div>
</td>
<td width="100px">
<div>我是第三列</div>
</td>
</tr>
</table>
</body>
</html>
标签:部分区域,高亮,遮罩层
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Flask教程之重定向与错误处理实例分析
2021-02-04 08:00:49
python调用c++传递数组的实例
2021-09-23 03:30:47
Python 函数基础知识汇总
2021-12-22 15:47:09
VS自带的SQL server修改密码并连接使用
2024-01-27 17:02:12
Python文件打开读取写入方法实用案例
2023-08-23 21:19:51
![](https://img.aspxhome.com/file/2023/2/61982_0s.png)
Pytorch图像处理注意力机制解析及代码详解
2023-10-05 03:23:03
![](https://img.aspxhome.com/file/2023/2/134892_0s.png)
12种最常用的网页编程语言简介(值得收藏)
2023-01-29 17:40:48
ASP连接MySQL数据库的方法
2010-03-14 11:25:00
Django结合ajax进行页面实时更新的例子
2023-02-14 21:15:45
![](https://img.aspxhome.com/file/2023/1/80581_0s.jpg)
Python+Turtle绘制幸运草的示例代码
2023-05-20 13:41:19
![](https://img.aspxhome.com/file/2023/0/77020_0s.png)
基于Python实现体育彩票选号器功能代码实例
2021-06-15 17:48:54
![](https://img.aspxhome.com/file/2023/9/118039_0s.png)
详解php处理大并发大流量大存储
2023-07-21 13:11:02
![](https://img.aspxhome.com/file/2023/8/555181_0s.jpg)
css命名及书写规范大全
2008-05-24 08:52:00
![](https://img.aspxhome.com/file/UploadPic/up/2008052409352233.gif)
Python程序员面试题 你必须提前准备!
2023-09-12 09:52:44
![](https://img.aspxhome.com/file/2023/4/91894_0s.jpg)
解决Python内层for循环如何break出外层的循环的问题
2023-09-07 22:21:39
基于OpenCV和Gradio实现简单的人脸识别详解
2022-10-21 22:59:11
![](https://img.aspxhome.com/file/2023/2/127772_0s.png)
python人工智能tensorflow常见损失函数LOSS汇总
2023-11-22 18:12:48
![](https://img.aspxhome.com/file/2023/7/64277_0s.png)
oracle 存储过程和函数例子
2023-06-26 08:19:30
Oracle11g简单安装和使用教程
2024-01-18 19:28:47
Python3.5字符串常用操作实例详解
2023-08-31 00:25:53
![](https://img.aspxhome.com/file/2023/8/62608_0s.png)