首頁  >  文章  >  web前端  >  jquery實作頂部向右伸縮的導航區域代碼_jquery

jquery實作頂部向右伸縮的導航區域代碼_jquery

WBOY
WBOY原創
2016-05-16 15:40:511135瀏覽

本文實例講述了jquery實作頂部向右伸縮的導航區域程式碼。分享給大家供大家參考。具體如下:

這是一款類似導航的選單,但擴展性比較強,不但可以用作選單,更可以用作導航區塊效果,導航區塊內可以含有選單或是其它的一些功能,本效果基於jQuery實現,用滑鼠點選浮動層左端的箭頭,即可合攏與伸開此選單。

運作效果截圖如下:

線上示範網址如下:

http://demo.jb51.net/js/2015/jquery-right-hidden-show-nav-style-codes/

具體程式碼如下:

<!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>鼠标单击控制收缩和展开的窗口</title>
<meta http-equiv="content-type" content="text/html;charset=gb2312">
<style type="text/css">
*{margin:0;padding:0;}
#box{position:absolute;right:0;top:0;overflow:hidden;}
#arrow{color:#fff;background:#000;width:20px;height:90px;line-height:90px;font-size:12px;font-family:"宋体";text-align:center;font-weight:bold;float:left;}
#col_box{width:400px;height:90px;background:#eee;float:left;}
</style>
<script type="text/javascript" src="jquery-1.6.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
 var oMoveBox = $("#col_box"), oArr = $("#arrow"), maxL = 400;
 oArr.click(function(){
  oMoveBox.animate({"width":"-="+maxL},600,function(){
   maxL = -maxL;
   $("#arrow").html(maxL<0 &#63; "<" : ">");
  })
 });
});
</script>
</head>
<body>
<div id="box">
 <div id="arrow">></div>
 <div id="col_box">z<br>z<br>s<br>k<br>y</div>
</div>
</body>
</html>

希望本文所述對大家的jquery程式設計有所幫助。

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn