CSS +js implementation of part of the region highlights editable mask layer

  • 2020-03-30 02:13:36
  • OfStack

I think you've all done a mask layer which is a very common function, CSS or jquery implementation, but it's a very diverse implementation, so here's the http:// I'm going to show you the way I implemented it in my project, full screen mask, some areas to work with, very useful.

The effect is as follows:
< img SRC = "border = 0 / / files.jb51.net/file_images/article/201403/201403041005301.gif? 20142410556 ">  
Js implementation:
 
<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> 

Page code:
 
<!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="#"> 
 Start the mask layer  
</a> 
</div> 
</td> 
<td style="vertical-align:top"> 
<div id="signSpanId" style="position:absolute;"></div> 
<div id="alert" align="top"> 
<h4> 
<span> 
 This is the highlighted area  
</span> 
</h4> 
<p> 
<label> 
 The user name  
</label> 
<input type="text" /> 
</p> 
<p> 
<label> 
 password  
</label> 
<input type="password" /> 
</p> 
<p> 
<input type="submit" value=" registered " /> 
<input type="reset" value=" reset " /> 
</p> 
</div> 

</td> 
<td width="100px"> 
<div> I'm the third column </div> 
</td> 
</tr> 
</table> 
</body> 
</html> 

Related articles: