带弹性展开的jQuery面板代码

<!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>带弹性展开的jQuery面板代码</title>
<style>
 
#content {
    width: 100%;
    margin: 0 auto;
}

#widget-overlay-container {
    position: absolute;
    width: 100%;
    height:199px;
    z-index: 1000;
    top: -199px;
    left: 0;
    display: block;
     padding: 0;
    background: #333;
    overflow: hidden;
    opacity:0.5;
     -webkit-box-shadow:0 0 2px rgba(0, 0, 0, 0.80);
    -moz-box-shadow:0 0 2px rgba(0, 0, 0, 0.80);
    box-shadow:0 0 2px rgba(0, 0, 0, 0.80);
}
 

 #overlay-open {
    position: absolute;
    margin: 0;
    right: 0;
    z-index: 999;
}
#overlay-open a {
    background-image: url( overlay_open.png);
    width: 40px;
    height: 40px;
    display: block;
    text-indent: -9999px;
}
#overlay-open a:hover { background-position: 0 -41px; }
#overlay-open a.close { background-position: -41px 0; }
#overlay-open a:hover.close { background-position: -41px -41px; }
</style>
</head>
<body>
 <div id="content">
<div id="widget-overlay-container">

 </div>
<div id="overlay-open"><a class="" href="#">Open Widget Area</a></div>
 eeeeeeeeeeeeeeeeeeeee</div>
 </div>
<script type="text/javascript" src="jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="jquery-ui-1.js"></script>
<script type="text/javascript">
jQuery(document).ready(function() {    
    var widgetOverlay = jQuery('#widget-overlay-container');
    var widgetTrigger = jQuery('#overlay-open a');
    
    var widgetOverlayHeight = widgetOverlay.height() + 3;
 
    
    widgetTrigger.toggle( function() {
        
        widgetOverlay.animate({
            top : 0
        }, 900, 'easeOutBounce');
        
        widgetTrigger.addClass('close');
        widgetTrigger.animate({
            marginTop : widgetOverlayHeight
        });    
     
    }, function() {
        
        widgetOverlay.animate({
            top : -widgetOverlayHeight
        }, 900, 'easeOutBounce');
        
        widgetTrigger.removeClass('close');
        widgetTrigger.animate({
            marginTop : 0  
        });            
    });
});
</script>
</body>
</html>

posted @ 2012-07-02 19:26  a fine day  阅读(158)  评论(0编辑  收藏  举报