You need to know the properties of
Code
<!DOCTYPE html> <html> <head> <meta charset="utf8"> <title>js拖拽效果</title> <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"> </script> </head> <body> <div style="width: 1000px;height: 1000px;background-color: pink"> 111111 <button onclick="showWindow()">点击显示弹框</button> </div> <!-- 遮罩层 --> <div id="cover" style="background: #000; position: absolute; left: 0px; top: 0px; width: 100%; filter: alpha(opacity=30); opacity: 0.3; display: none; z-index: 2 "> </div> <!-- 弹窗 --> <div id="showdiv" style="width: 80%; margin: 0 auto; height: 9.5rem; border: 1px solid #999; display: none; position: absolute; top: 40%; left: 10%; z-index: 3; background: #fff"> ->Title<! - < Div style = "background: # F8F7F7; width: 100%; height: 2rem; font-size: 0.65rem; Line-height: 2rem; border: 1px Solid # 999; text-align = left: Center;" > Tip </ div > ! <- content -> < div style = "text-indent: 50px; height: 4rem; font-size: 0.5rem; padding: 0.5rem; Line-height: 1 rem;" > js js pop pop dIV, and darken the entire page background </ div > <-! button -> < div style="background: #418BCA; width: 80%; margin: 0 auto; height: 1.5rem; line-height: 1.5rem; text-align: center;color: #fff;margin-top: 1rem; -moz-border-radius: .128rem; -webkit-border-radius: .128rem; border-radius: .128rem;font-size: .59733rem;" onclick="closeWindow()"> 确 定 </div> </div> </body> <script type="text/javascript"> // 弹窗 function showWindow() { $('#showdiv').show(); //显示弹窗 $('#cover' ) .Css ( ' the display ' , ' Block ' ); // display mask layer $ ( ' #cover ' ) .css ( ' height ' , document.body.clientHeight + ' PX ' ); // Set the mask height of the current page layer height } // Close popup function closeWindow () { $ ( ' #showdiv ' ) .hide (); // hides pop $ ( ' #cover ' ) .css ( ' the display ', ' None ' ); // display mask layer } </ Script > </ HTML >