jquery Simple Popup Layer

Source: Internet
Author: User

Pre-defined HTML code: no

All code is generated and removed via JS.

Pre-defined CSS

/*Basic pop-up layer style*/. My-popup-overlay{width:100%;Height:Auto;/*width height is defined by JavaScript*/position:Absolute;Top:0; Left:0;Z-index: +;Background-color:#000;Opacity:0.2;*filter:Alpha (OPACITY=20);}. My-popup{position:fixed;Top:200px; Left:50%;/*margin-left:; defined by JS*/_position:Absolute;_top:expression (eval (Document.documentElement.scrollTop +));padding:10px;-moz-border-radius:5px;-webkit-border-radius:5px;Border-radius:5px;background:Gray;Z-index:1001;}. My-popup-close{position:Absolute;Top:10px; Right:10px;font-size:16px;width:20px;Height:20px;text-align:Center;Line-height:20px;background:#0aa;Color:#f00;cursor:Pointer;}. My-popup-close:hover{text-decoration:None;Color:#fff;Font-weight:Bold;}. My-popup-content{Background-color:#fff;}/*pop-up Layer style customization Section*/. Popup-title{padding:25px 0 10px;font-size:14px;text-align:Center;}. Popup-inner{width:300px;padding:20px;}
View Code

Plug-in code and application examples

(function ($) {    /** jquery Simple popup layer * Subject content passed in as parameters*/    varPopup =function(HTML) {//the body of the HTML popup layer        //A pop-up layer with a mask        var$overlay = $ ("<div class= ' My-popup-overlay ' ></div>"),            //define only the border and the Close button, and the rest are defined in the parameters$popup = $ ("<div class= ' My-popup ' >" + "<a class= ' my-popup-close ' >x</a>" + "<div class= ' my-popup-content ' >" +(HTML? HTML: "") + "</div>" + "</div>"); return{show:function () {                //$overlay and $popup append to Body$ ("Body"). Append ($overlay). Append ($popup); varthat = This;                $overlay. css ({width: $ (window). Width (), Height: $ (document). Height ()                }); $popup. css ({"Margin-left":-($popup. Width ()/2) + "px"                }); $(". My-popup-close"). On ("click",function() {that.hide ();            }); }, Hide:function () {                //Removing this mask and pop-up layer$overlay. Remove ();            $popup. Remove ();    }        };    }; //Application Examples    varpup1html = ' 

; varPopup1 =NewPopup (pup1html); Popup1.show ();}) (jQuery);

View Code

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.