欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

jquery實(shí)現(xiàn)點(diǎn)擊彈出層效果的簡(jiǎn)單實(shí)例

 更新時(shí)間:2014年03月03日 09:38:41   作者:  
本篇文章主要是對(duì)jquery實(shí)現(xiàn)點(diǎn)擊彈出層效果的簡(jiǎn)單實(shí)例進(jìn)行了介紹,需要的朋友可以過(guò)來(lái)參考下,希望對(duì)大家有所幫助

彈出層在實(shí)際應(yīng)用中我們經(jīng)常會(huì)碰到大量的彈出層效果,下面我來(lái)做一個(gè)基于jquery的簡(jiǎn)單的彈出層效果實(shí)例,各位朋友有興趣可參考。

效果代碼如下:


在 彈出層 中下面是核心代碼

復(fù)制代碼 代碼如下:

<script type="text/javascript">
// 漸變彈出層
$(document).ready(function(){
 var speed = 600;//動(dòng)畫(huà)速度
 $("#race a").click(function(event){//綁定事件處理
  event.stopPropagation();
  var offset = $(event.target).offset();//取消事件冒泡
  $("#racePop").css({ top:offset.top + $(event.target).height() + "px", left:offset.left });//設(shè)置彈出層位置
  $("#racePop").show(speed);//動(dòng)畫(huà)顯示
 });
 $(document).click(function(event) { $("#racePop").hide(speed) });//單擊空白區(qū)域隱藏
 $("#racePop").click(function(event) { $("#racePop").hide(speed) });//單擊彈出層則自身隱藏

});
</script>

完整實(shí)例
復(fù)制代碼 代碼如下:

<!-- 漸變彈出層 -->
<div id="race"><a href="#">點(diǎn)擊</a></div>
<div id="racePop" class="raceShow">這里是彈出層效果</div>


<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
// 漸變彈出層
$(document).ready(function(){
 var speed = 600;//動(dòng)畫(huà)速度
 $("#race a").click(function(event){//綁定事件處理
  event.stopPropagation();
  var offset = $(event.target).offset();//取消事件冒泡
  $("#racePop").css({ top:offset.top + $(event.target).height() + "px", left:offset.left });//設(shè)置彈出層位置
  $("#racePop").show(speed);//動(dòng)畫(huà)顯示
 });
 $(document).click(function(event) { $("#racePop").hide(speed) });//單擊空白區(qū)域隱藏
 $("#racePop").click(function(event) { $("#racePop").hide(speed) });//單擊彈出層則自身隱藏

});
</script>

<style>
body{margin:0 auto;font:12px/1.5 tahoma,arial,5b8b4f53;color:#828282;background:#fff}
body,h1,h2,h3,h4,h5,h6,p,ul,li,dl,dt,dd{padding:0;margin:0;}
li{list-style:none;}img{border:none;}em{font-style:normal;}
a{color:#555;text-decoration:none;outline:none;blr:this.onFocus=this.blur();}
a:hover{color:#000;text-decoration:underline;}
body{font-size:12px;font-family:Arial,Verdana, Helvetica, sans-serif;word-break:break-all;word-wrap:break-word;}
.clear{height:0;overflow:hidden;clear:both;}

/* 漸變彈出層 */
#race{display:block;width:200px;height:50px;line-height:50px;text-align:center;background:#CCC;border:#555 1px solid;margin:10px auto}
.raceShow{background-color:#f1f1f1;border:solid 1px #ccc;position:absolute;display:none;width:300px;height:100px;padding:5px;font-size:12px;}

</style>

相關(guān)文章

最新評(píng)論