jquery 點擊彈出層

來源:互聯網
上載者:User

<!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>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<?php教程
 /*超簡潔完美遮罩彈出層,無視解析度,頁面高度任意,彈出層高度任意
  * 唯一需要注意的是如果css教程寫的不標準.那麼頁面body的實際高度就不一定要是頁面真實高度.位置高度就無法計算準確.
  */
?>
<script type="text/網頁特效" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<style><!--*{ margin:0; padding:0; font-size:13px;}.d{height:100%;left:0;position:absolute;top:0;width:100%;background:#aaa;opacity:0.2;filter:alpha(opacity=20)}#b{ z-index:200; }--></style>
<body>
<br /><br /><br /><br /><br /><br /><br />
<a id="a" href="javascript:viod(0)">彈出</a>
<div class="d" style="z-index: 100; display:none"></div>
<div id="b"  style="width:650px; height:650px; background:#ccc;  display:none">這是彈出層<a id="c" href="javascript:viod(0)">關閉</a></div>
</body>
<script>
$(document).ready(function(){
 // .d是遮罩層層
 // #b是彈出層
 $("#a").bind("click",function(){
  //這裡是body_height
  if($('body').height() < $(window).height()){  
   var body_height = $(window).height();
  }else{
   var body_height = $(document).height();
  } 
  var left = $(window).width();
  var layer_height = $('#b').height();
  var layer_width = $('#b').width();
  $("#b").css("position","absolute");
  $("#b").css("top",(body_height-$(window).height()+($(window).height()-layer_height)/2));
  $("#b").css("left",(left-layer_width)/2);
  $(".d").css("height",$(document).height());
  $("#b").fadein('fast');
  $(".d").show();
 });
 $("#c").bind("click",function(){
  $("#b").hide();
  $(".d").hide();
 });
});
</script>

源碼下載
http://down.111cn.net/down/code/jquery/2010/1009/21116.html 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.