天天看點

漸變彈出層

<!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=utf-8" />

<title>漸變彈出層</title>

<script type="text/javascript" src="common/jquery-1.2.6.min.js"></script>

<link type="text/css" rel="stylesheet" href="common/common.css" />

<style>

/* 漸變彈出層 */

#race{display:block;width:200px;height:50px;line-height:50px;text-align:center;background:#ccc;border:#555 1px solid;}

.raceshow{background-color:#f1f1f1;border:solid 1px #ccc;position:absolute;display:none;width:300px;height:100px;padding:5px;font-size:12px;}

#uplayer span{border:#fff 1px solid; width:80px; padding:0 5px; line-height:20px; display:block;}

#uplayer ul{display:none;position:absolute;border:#ccc 1px solid;width:80px; padding:5px; line-height:20px; background:#f1f1f1; margin:-1px 0 0 0;}

#uplayer ul li{ border-bottom:#ccc 1px dashed;}

</style>

</head>

<body>

<script type="text/javascript">

// 漸變彈出層

$(document).ready(function(){

 var speed = 600;//動畫速度

 $("#race a").click(function(event){//綁定事件處理

  event.stoppropagation();

  var offset = $(event.target).offset();//取消事件冒泡

  $("#racepop").css({ top:offset.top + $(event.target).height() + "px", left:offset.left });//設定彈出層位置

  $("#racepop").show(speed);//動畫顯示

 });

 $(document).click(function(event) { $("#racepop").hide(speed) });//單擊空白區域隐藏

 $("#racepop").click(function(event) { $("#racepop").hide(speed) });//單擊彈出層則自身隐藏

 var objstr = "#uplayer";

 $(objstr).mouseover(function(){$(objstr + " ul").show();});

 $(objstr).mouseout(function(){$(objstr + " ul").hide();});

});

</script>

<!-- 漸變彈出層 -->

<div id="race"><a href="#">點選</a></div>

<div id="racepop" class="raceshow">這裡是彈出層效果</div>

<div id="uplayer">

 <span><a href="javascript:void(0)">彈出層</a></span>

    <ul>

        <li><a href="#">手機資訊</a></li>

        <li><a href="#">熱門文章</a></li>

        <li><a href="#">聯系站長</a></li>

        <li><a href="#">建議意見</a></li>

    </ul> 

</div>

</body>

</html>

繼續閱讀