Eject the simplest modular mask layer of the JS code

Source: Internet
Author: User

  Pop-up mask layer has a lot of methods, in this article for you to use JS to achieve the simplest pattern mask layer, specifically as follows, interested friends do not miss

Suppose we have a container container the following:  code as follows: <style type= "Text/css" >  #container {width:auto;height:auto; overflow: Hidden;}  /* The Overflow:hidden property is primarily designed to automatically hide parts that exceed container, and this property is set to address IE8 and the following version of browser compatibility issues */  </style>   <div id= "container" >  </div>      now to pop a div layer on the Web page so that you can't manipulate container before you close the div layer that pops up.   Well, we first need to define the div layer of this mask as follows:  code as follows: <div id= "Continer" >  <!-only so put the mask layer in the container inside   < Divid= "Shade" style= width:1600px;height:900px;/* to mask layer an initial size * * ">  <input name=" Close "id=" Close "value=" Close ">  </div>  </div>   " Next, is to use JS to make the mask layer always displayed on the screen does not operate the mask layer below the content, click the Close button to close the mask layer   The code is as follows: <script type= "Text/javascript" >  $ (function () { //Get the current browser's internal width and height   Varnwidth = window.innerwidth;  varnheight = window.innerheight; //Set mask layer width and height   $ ("#shade"). Width (nwidth);  $ ("#shade"). Height (nheight); //Set Close button Center display   $ ("#close"). CSS ("Margin-top", nheight/2-50+ "px"); //Set events triggered when browser size changes   $ (window). Resize (function () { //Get the current browser's interior width and height   Varnwidth = window.innerwidth;  varnheight = window.innerheight; //Set mask layer width and height   $ ("#shade"). Width (nwidth);  $ ("#shade"). Height (nheight); //Set Close button Center display   $ ("#putPwd"). CSS ("Margin-top", nheight/2-50+ "px"); });  //Set off button to eliminate mask layer   $ ("#close"). Click (function () {  $ ("#shade"). REMOVEATTR ("id");  $ ("#shade"). HTML (""); }); //can also be used in pure JS to write   document.getElementById ("shade") .style.......; //back to say no more, if interested and really can't write, Can contact with me.  })   </script>     
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.