您好,登錄后才能下訂單哦!
ys_popup.css
.ys-popup{ position:fixed; top:0; bottom:0; left:0; right:0; display:none; z-index: 99999; background-color: rgba(0,0,0,0.4); } .ys-popup .ys-popup-content{ position:absolute; left:30px; right:30px; top:50%; display:block; background-color:#fff; margin:auto; border-radius: 4px; }
ys_popup.js
(function($){ function closePopup(target){ $(target).hide(); } function showPopup(target){ $(target).show(); $(target).css("visibility","hidden"); var popupContentHeight = parseInt($(target).find(".ys-popup-content").css("height")); $(target).find(".ys-popup-content").css({ "margin-top":(-1)*popupContentHeight/2+"px" }); $(target).css("visibility","initial"); } $("body").on("click",".ys-popup",function(e){ e.stopPropagation(); e.preventDefault(); $(this).hide(); }); $("body").on("click",".ys-popup .ys-popup-content",function(e){ e.stopPropagation(); e.preventDefault(); }); var options = { ysPopup:function(command) { if(command=="show"){ showPopup(this); }else if(command=="hide"){ closePopup(this); }else{ showPopup(this); } } }; $.fn.extend(options); })(jQuery);
測試
<div class="ys-popup remark-popup" > <div class="ys-popup-content"> <div class="remark-popup-title">備注</div> <div class="remark-popup-content"><textarea placeholder="請輸入備注"></textarea></div> <div class="remark-popup-btn-group clearfix"> <a class="remark-popup-cancel">取消</a> <a class="remark-popup-ok">確認(rèn)</a> </div> </div> </div><!-- activity-success-popup --> <script> $(".ys-popup").ysPopup("show");// 顯示彈出框 $(".ys-popup").ysPopup("hide");// 隱藏彈出框 </script>
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。