您好,欢迎来到源码搜藏!分享精神,快乐你我!提示:担心找不到本站?在百度搜索“源码搜藏”,网址永远不丢失!
  • 首 页
  • 在线工具
  • 当前位置:首页 > 网页特效 > 表格图层 >

    可关闭jQuery浮动层插件,点击按钮弹出层

    时间:2014-04-16 08:37 来源:互联网 作者:源码搜藏 浏览:收藏 挑错 推荐 打印

    运行代码保存代码复制代码 提示:您可以先修改部分代码再运行,保存代码功能在Firefox下无效。
    • 小鸟jquery弹出层插件,由漫画Jquery弹出层插件改编而来,小鸟Js弹窗插件,按ESC可以关闭窗口。默认不带样式,大家可以根据自己的项目写样式。弹出层代码很小,min版的只1.15k,因为小所以值得应用。希望有网友可以再改进,希望她变得更校
    • <!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>jquery实现可拖动弹出层特效</title>
      <script src="http://www.codefans.net/ajaxjs/jquery-1.7.2.min.js" type="text/javascript"></script>
      <script type="text/javascript">
      function popWin(a){function n(){var a=k?k:document.body,b=a.scrollHeight>a.clientHeight?a.scrollHeight:a.clientHeight,c=a.scrollWidth>a.clientWidth?a.scrollWidth:a.clientWidth;$("#maskLayer").css({height:b,width:c})}var d,e,b=9e3,c=!1,f=$("#"+a),g=f.width(),h=f.height(),i=f.find(".tit"),j=f.find(".close"),k=document.documentElement,l=($(document).width()-f.width())/2,m=(k.clientHeight-f.height())/2;f.css({left:l,top:m,display:"block","z-index":b- -1}),i.mousedown(function(a){c=!0,d=a.pageX-parseInt(f.css("left")),e=a.pageY-parseInt(f.css("top")),f.css({"z-index":b- -1}).fadeTo(50,.5)}),i.mouseup(function(){c=!1,f.fadeTo("fast",1)}),$(document).mousemove(function(a){if(c){var b=a.pageX-d;0>=b&&(b=0),b=Math.min(k.clientWidth-g,b)-5;var i=a.pageY-e;0>=i&&(i=0),i=Math.min(k.clientHeight-h,i)-5,f.css({top:i,left:b})}}),j.live("click",function(){$(this).parent().parent().hide().siblings("#maskLayer").remove()}),$('<div id="maskLayer"></div>').appendTo("body").css({background:"#000",opacity:".4",top:0,left:0,position:"absolute",zIndex:"8000"}),n(),$(window).bind("resize",function(){n()}),$(document).keydown(function(a){27==a.keyCode&&($("#maskLayer").remove(),f.hide())})}
      </script>
      <style type="text/css">
      body{margin:0; padding:0;font-size:12px;}
      dt{padding:10px;}
      p{ height:100px; line-height:100px; border:1px solid #eee; margin:10px; }
      i{ font-style:normal;}
      #detail{ position:absolute;width:400px;height:200px;border:1px solid #ccc;background:#efefef; display:none;}
      #detail .tit{ background:#ddd; display:block; height:33px; cursor:move;}
      #detail .tit i{ float:right; line-height:33px; padding:0 8px;cursor:default;}
      #detail2{position:absolute;width:300px;height:100px;border:1px solid #555;background:#555;display:none;}
      #detail2 .tit{ background:#333; display:block; height:33px;cursor:move;}
      #detail2 .tit i{ float:right; line-height:33px; padding:0 8px; color:#777; cursor:default;}
      </style>
      </head>
      <body>
      <br /><br />
      <center>
      <dl>
      <dt><button id="t1">点我弹一个</button></dt>
          <dt><button  id="t2">点我再弹一个</button></dt>
      </dl>
      </center>
      <div id="detail">
      <div class="tit"><i class="close">关闭</i></div>
      </div>
      <div id="detail2">
      <div class="tit"><i class="close">关闭</i></div>
      再弹出一个窗
      </div>
      <script type="text/javascript">
      $("#t1").click(function(){
      popWin("detail");
      });
      $("#t2").click(function(){
      popWin("detail2");
      });
      </script>
      <div style="text-align:center;margin:50px 0; font:normal 14px/24px 'MicroSoft YaHei';">
      </div>
      </body>
      </html>
    可关闭jQuery浮动层插件,点击按钮弹出层由源码搜藏网整理,转载请注明出处http://www.codesocang.com/texiao/biaoge/7113.html
    标签:网站源码