Show matte layers and pop-up boxes

Source: Internet
Author: User

Because recently used the mask layer and pop-up box, the Internet to check the data after the completion of a, do a record here to save.

Because of the use of JQ, it is necessary to introduce JQ files, such as Jquery-1.11.3.js

Here's the code for the JSP:

<body>
<div>
<input id= "button" type= "button" value= "click me" >
<div class= "Sharedialog" >
<div class= "Dialog-top" >
<span> Mobile </span><a class= "Home-btn-close" >x</a>
</div>
<div class= "Sharedialogchild" >hello world</div>
</div>
</div>
<div class= "Backscreen" ></div>
</body>

The following is the code for the CSS file:

/** Popup Box **/
. sharedialog{
width:400px;
height:400px;
left:167px;
top:42.5px;
z-index:2000;
Position:absolute;
Background: #fff;
BORDER:3PX solid #95B8E7;
Display:none;
}

/** the top blue part of the popup box **/
. dialog-top{
Cursor:move!important;
width:400px;
height:35px;
Position:absolute;
left:0;
top:0;
font-size:12px;
Background-color: #95B8E7;
z-index:999;
}

. sharedialogchild{
width:400px;
height:400px;
Overflow:auto;
}

. home-btn-close{
Position:absolute;
top:5px;
right:10px;
width:25px;
height:25px;
line-height:25px;
Text-align:center;
Vertical-align:middle;
font-size:30px;
Color: #333;
Background:transparent;
border-radius:50%;
Cursor:pointer;
Font:normal 25px/25px "Helvetica Neue", Hevetica Arial,sans-serif;
Border:none;
-wekit-transition:background-color. 2s ease;
-o-transition:background-color. 2s ease;
-moz-transition:background-color. 2s ease;
Transition:background-color. 2s ease;
}

/** Mask Layer **/
. backscreen{
position:fixed;
left:0;
top:0;
right:0;
bottom:0;
z-index:999;
Background-color: #000;
opacity:0.75;
Display:none;
}

The following is the code for the JS file:

$ (function () {
$ ("#button"). Click (function () {
$ (". Backscreen"). Show ();
$ (". Sharedialog"). CSS ("Display", "block");
});

Initposition ();
Draganddrop ();

$ (". Dialog-top. Home-btn-close"). Click (function (e) {
$ (". Sharedialog"). Hide ();
$ (". Backscreen"). Hide ();
});
});

/**
* Popup Box drag and drop
*/
function Draganddrop () {
var _move = false;
var _x,_y;
$ ('. Dialog-top '). MouseDown (function (e) {
_move = true;
_x = E.pagex-parseint ($ (". Sharedialog"). CSS ("left"));
_y = E.pagey-parseint ($ (". Sharedialog"). CSS ("top"));
});
$ (document). MouseMove (function (e) {
if (_move) {
var x = E.pagex-_x;
var y = e.pagey-_y;
$ (". Sharedialog"). CSS ({
Top:y,
Left:x
});
}
}). MouseUp (function () {
_move = false;
});
}

/**
* Initialize the location of the drag popup div
*/
function Initposition () {
Calculate Initialization Location
var itop = ($ (document). Height ()-$ (". Sharedialog"). Height ())/10;
var ILeft = ($ (document). Width ()-$ (". Sharedialog"). Width ())/8;
Set the position of the div being dragged
$ (". Sharedialog"). CSS ({
Top:itop,
Left:ileft
});
}

After running the following:

Click on the "click Me" in the upper left corner, pop-up mask layer and pop-up, you can click on the top of the pop-up box in the Blue section, drag the popup box, click on the upper right corner will close the bounce and mask layer.

Show matte layers and pop-up boxes

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.