Simple Mask Layer

Source: Internet
Author: User

Effect:

Download:/files/jaylong/concealer .rar

1. source code of the heml page:

<SCRIPT type = "text/JavaScript" src = "jquery-1.4.1.js"> </SCRIPT>
<SCRIPT type = "text/JavaScript" src = "noname3.js"> </SCRIPT>
<LINK rel = "stylesheet" type = "text/CSS" href = "noname2.css">

<Div id = "con"> <span id = "click"> <a href = "#"> click me </a> </span> </div>
<Div id = "shade"> I am the pop-up Mask Layer
<Div id = "closebtn"> close </div>
</Div>

2.css File

 

# Con
{
Margin : 200px ;
}
# Shade
{
Display : None ;
Position : Absolute ; /* Set to absolute location */
Width : 400px ;
Height : 200px ;
Border : # Bfe5b3 solid 1px ;
Z-Index : 200 ; /* Set Cascade */
Background : # Fff ;
}
/* ** Mask layer *** */
# Greybackground
{
Background : #000 ;
Display : Block ;
Z-Index : 100 ;
Width : 100% ;
Position : Absolute ;
Top : 0 ;
Left : 0 ;
}
# Closebtn
{
Position : Absolute ;
Top : 10px ;
Left : 340px ;
}

 

3. jsCode

 

$ ( Function (){
VaR Screenwidth, screenheight, mytop, getposleft, getpostop
Screenwidth = $ (Window). Width ();
Screenheight = $ (Window). Height ();
// Obtains the offset of the scroll bar from the top.
Mytop = $ (Document). scrolltop ();
// Calculate the left of the pop-up layer
Getposleft = Screenwidth /   2   -   200 ;
// Calculate the top of the pop-up layer
Getpostop = Screenheight /   2   -   150 ;
// CSS position pop-up layer
$ ( " # Shade " ).Css ({ " Left " : Getposleft, " Top " : Getpostop });
// When the browser window size changes
$ (Window). Resize ( Function (){
Screenwidth = $ (Window). Width ();
Screenheight = $ (Window). Height ();
Mytop = $ (Document). scrolltop ();
Getposleft = Screenwidth /   2   -   200 ;
Getpostop = Screenheight /   2   -   150 ;
$ ( " # Shade " ).Css ({ " Left " : Getposleft, " Top " : Getpostop + Mytop });
});
// When the scroll bar is pulled, the pop-up layer moves
$ (Window). Scroll ( Function (){
Screenwidth = $ (Window). Width ();
Screenheight = $ (Window). Height ();
Mytop = $ (Document). scrolltop ();
Getposleft = Screenwidth /   2   -   200 ;
Getpostop = Screenheight /   2   -   100 ;
$ ( " # Shade " ).Css ({ " Left " : Getposleft, " Top " : Getpostop + Mytop });
});
// Click the link to bring up the logon window.
$ ( " # Click " ). Click ( Function (){
$ ( " # Shade " ). Fadein ( " Slow " ); // Toggle ("slow ");
// Retrieve the document height on the page
VaR Docheight = $ (Document). Height ();
// Append a layer to make the background gray
$ ( " Body " ). Append ( " <Div id = 'greybackground '> </div> " );
$ ( " # Greybackground " ).Css ({ " Opacity " : " 0.5 " , " Height " : Docheight });
Return   False ;
});
// Click Close.
$ ( " # Closebtn " ). Click ( Function (){
$ ( " # Shade " ). Fadeout ( " Slow " ); // // Hide ();
// Delete the dimmed Layer
$ ( " # Greybackground " ). Remove ();
Return   False ;
});
});

 

 

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.