jquery實現(xiàn)簡單實用的彈出層效果代碼
本文實例講述了jquery實現(xiàn)簡單實用的彈出層效果。分享給大家供大家參考。具體如下:
目前來說,我還是喜歡這個自己改造的彈出層,在項目中用的也是這個。引入了新版的jquery插件,方框及文字都可以自己定義,非常方便,希望大家也喜歡這款彈出層,JavaScript在本例中也充分發(fā)揮了作用,對學(xué)習(xí)JS也是不錯的參考。
運行效果截圖如下:
在線演示地址如下:
http://demo.jb51.net/js/2015/jquery-simple-alert-style-demo/
具體代碼如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>彈出層</title> <script src="jquery-1.6.2.min.js" type="text/javascript"></script> <style> .black_overlay{ display: none; position: absolute; top: 0%; left: 0%; width: 100%; height: 100%; background-color: black; z-index:1001; -moz-opacity: 0.8; opacity:.80; filter: alpha(opacity=80); } .white_content { display: none; position: absolute; top: 10%; left: 10%; width: 80%; height: 80%; border: 16px solid lightblue; background-color: white; z-index:1002; overflow: auto; } .white_content_small { display: none; position: absolute; top: 20%; left: 30%; width: 40%; height: 50%; border: 16px solid lightblue; background-color: white; z-index:1002; overflow: auto; } </style> <script type="text/javascript"> //彈出隱藏層 function ShowDiv(show_div,bg_div){ document.getElementById(show_div).style.display='block'; document.getElementById(bg_div).style.display='block' ; var bgdiv = document.getElementById(bg_div); bgdiv.style.width = document.body.scrollWidth; // bgdiv.style.height = $(document).height(); $("#"+bg_div).height($(document).height()); }; //關(guān)閉彈出層 function CloseDiv(show_div,bg_div) { document.getElementById(show_div).style.display='none'; document.getElementById(bg_div).style.display='none'; }; </script> </head> <body> <input id="Button1" type="button" value="點擊彈出層" onclick="ShowDiv('MyDiv','fade')" /> <!--彈出層時背景層DIV--> <div id="fade" class="black_overlay"> </div> <div id="MyDiv" class="white_content"> <div style="text-align: right; cursor: default; height: 40px;"> <span style="font-size: 16px;" onclick="CloseDiv('MyDiv','fade')">關(guān)閉</span> </div> 目前來說,我還是喜歡這個自己改造的彈出層。自己在項目中也用的是這個。 </div> </body> </html>
希望本文所述對大家的jquery程序設(shè)計有所幫助。
相關(guān)文章
Jquery創(chuàng)建層顯示標(biāo)題和內(nèi)容且隨鼠標(biāo)移動而移動
本文為大家介紹下使用Jquery創(chuàng)建一個層顯示標(biāo)題的內(nèi)容且隨鼠標(biāo)移動,具體的實現(xiàn)如下2014-01-01JQuery+JS實現(xiàn)仿百度搜索結(jié)果中關(guān)鍵字變色效果
JQuery+JS實現(xiàn)仿百度搜索結(jié)果中關(guān)鍵字變色效果代碼,需要的朋友可以參考下。2011-08-08jQuery中each循環(huán)的跳出和結(jié)束實例
下面小編就為大家?guī)硪黄猨Query中each循環(huán)的跳出和結(jié)束實例。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-08-08