Jquery+CSS 創(chuàng)建流動導(dǎo)航菜單 Fluid Navigation
更新時(shí)間:2010年02月23日 14:31:45 作者:
有時(shí),一個(gè)網(wǎng)站的導(dǎo)航菜單文字不能提供足夠的信息,來表達(dá)當(dāng)前菜單按鈕的內(nèi)容,一般的解決辦法是使用提示信息ToolTip,那么本文介紹的流動導(dǎo)航菜單Fluid Navigation也可以解決此問題,同時(shí)也為網(wǎng)站設(shè)計(jì)的添加了一些時(shí)尚而又動感元素。
那么我們應(yīng)該如何實(shí)現(xiàn)流動導(dǎo)航菜單呢?
一、效果圖

鼠標(biāo)滑過Menu,即Show提示信息。
二、實(shí)現(xiàn)步驟
1、CSS代碼
menuBarHolder { width: 730px; height:45px; background-color:#000; color:#fff; font-family:Arial; font-size:14px; margin-top:20px;}
#menuBarHolder ul{ list-style-type:none; display:block;}
#container { margin-top:100px;}
#menuBar li{ float:left; padding:15px; height:16px; width:50px; border-right:1px solid #ccc; }
#menuBar li a{color:#fff; text-decoration:none; letter-spacing:-1px; font-weight:bold;}
.menuHover { background-color:#999;}
.firstchild { border-left:1px solid #ccc;}
.menuInfo { cursor:hand; background-color:#000; color:#fff;
width:74px; font-size:11px;height:100px; padding:3px; display:none;
position:absolute; margin-left:-15px; margin-top:-15px;
-moz-border-radius-bottomright: 5px;
-moz-border-radius-bottomleft: 5px;
-webkit-border-bottom-left-radius: 5px;
-webkit-border-bottom-right-radius: 5px;
-khtml-border-radius-bottomright: 5px;
-khtml-border-radius-bottomleft: 5px;
border-radius-bottomright: 5px;
border-radius-bottomleft: 5px;
}
menuBarHolder: 菜單Menu的固定容器,寬度=730px。
menuInfo:控制提示信息的展示與否。
2、HTML代碼
<div id="menuBarHolder">
<ul id="menuBar">
<li class="firstchild"><a href="javascript:#">Home</a>
<div class="menuInfo">I am some text about the home section</div></li>
<li><a href="javascript:#">Services</a>
<div class="menuInfo">I am some text about the services section</div></li>
<li><a href="javascript:#">Clients</a>
<div class="menuInfo">I am some text about the clients section</div></li>
<li><a href="javascript:#">Portfolio</a>
<div class="menuInfo">I am some text about the portfolio section</div></li>
<li><a href="javascript:#">About</a>
<div class="menuInfo">I am some text about the about section</div></li>
<li><a href="javascript:#">Blog</a>
<div class="menuInfo">I am some text about the blog section</div></li>
<li><a href="javascript:#">Follow</a>
<div class="menuInfo">I am some text about the follow section</div></li>
<li><a href="javascript:#">Contact</a>
<div class="menuInfo">I am some text about the contact section</div></li>
</ul>
</div>
UI LI元素:列表元素。
DIV元素:提示內(nèi)容信息。
3、Javascript代碼
$(document).ready(function()
{
$('#menuBar li').click(function()
{
var url = $(this).find('a').attr('href');
document.location.href = url;
});
$('#menuBar li').hover(function()
{
$(this).find('.menuInfo').slideDown();
},
function()
{
$(this).find('.menuInfo').slideUp();
});
});
click()、 hover():給Li元素綁定單擊事件和鼠標(biāo)滑過事件。
find()函數(shù):搜索所有與指定表達(dá)式匹配的元素。這個(gè)函數(shù)是找出正在處理的元素的后代元素的好方法。
slideDown(speed, [callback]):通過高度變化(向下增大)來動態(tài)地顯示所有匹配的元素,在顯示完成后可選地觸發(fā)一個(gè)回調(diào)函數(shù)。
slideUp(speed, [callback]):通過高度變化(向上減?。﹣韯討B(tài)地隱藏所有匹配的元素,在隱藏完成后可選地觸發(fā)一個(gè)回調(diào)函數(shù)。
[Ctrl+A 全選 注:引入外部Js需再刷新一下頁面才能執(zhí)行]
一、效果圖

鼠標(biāo)滑過Menu,即Show提示信息。
二、實(shí)現(xiàn)步驟
1、CSS代碼
復(fù)制代碼 代碼如下:
menuBarHolder { width: 730px; height:45px; background-color:#000; color:#fff; font-family:Arial; font-size:14px; margin-top:20px;}
#menuBarHolder ul{ list-style-type:none; display:block;}
#container { margin-top:100px;}
#menuBar li{ float:left; padding:15px; height:16px; width:50px; border-right:1px solid #ccc; }
#menuBar li a{color:#fff; text-decoration:none; letter-spacing:-1px; font-weight:bold;}
.menuHover { background-color:#999;}
.firstchild { border-left:1px solid #ccc;}
.menuInfo { cursor:hand; background-color:#000; color:#fff;
width:74px; font-size:11px;height:100px; padding:3px; display:none;
position:absolute; margin-left:-15px; margin-top:-15px;
-moz-border-radius-bottomright: 5px;
-moz-border-radius-bottomleft: 5px;
-webkit-border-bottom-left-radius: 5px;
-webkit-border-bottom-right-radius: 5px;
-khtml-border-radius-bottomright: 5px;
-khtml-border-radius-bottomleft: 5px;
border-radius-bottomright: 5px;
border-radius-bottomleft: 5px;
}
menuBarHolder: 菜單Menu的固定容器,寬度=730px。
menuInfo:控制提示信息的展示與否。
2、HTML代碼
復(fù)制代碼 代碼如下:
<div id="menuBarHolder">
<ul id="menuBar">
<li class="firstchild"><a href="javascript:#">Home</a>
<div class="menuInfo">I am some text about the home section</div></li>
<li><a href="javascript:#">Services</a>
<div class="menuInfo">I am some text about the services section</div></li>
<li><a href="javascript:#">Clients</a>
<div class="menuInfo">I am some text about the clients section</div></li>
<li><a href="javascript:#">Portfolio</a>
<div class="menuInfo">I am some text about the portfolio section</div></li>
<li><a href="javascript:#">About</a>
<div class="menuInfo">I am some text about the about section</div></li>
<li><a href="javascript:#">Blog</a>
<div class="menuInfo">I am some text about the blog section</div></li>
<li><a href="javascript:#">Follow</a>
<div class="menuInfo">I am some text about the follow section</div></li>
<li><a href="javascript:#">Contact</a>
<div class="menuInfo">I am some text about the contact section</div></li>
</ul>
</div>
UI LI元素:列表元素。
DIV元素:提示內(nèi)容信息。
3、Javascript代碼
復(fù)制代碼 代碼如下:
$(document).ready(function()
{
$('#menuBar li').click(function()
{
var url = $(this).find('a').attr('href');
document.location.href = url;
});
$('#menuBar li').hover(function()
{
$(this).find('.menuInfo').slideDown();
},
function()
{
$(this).find('.menuInfo').slideUp();
});
});
click()、 hover():給Li元素綁定單擊事件和鼠標(biāo)滑過事件。
find()函數(shù):搜索所有與指定表達(dá)式匹配的元素。這個(gè)函數(shù)是找出正在處理的元素的后代元素的好方法。
slideDown(speed, [callback]):通過高度變化(向下增大)來動態(tài)地顯示所有匹配的元素,在顯示完成后可選地觸發(fā)一個(gè)回調(diào)函數(shù)。
slideUp(speed, [callback]):通過高度變化(向上減?。﹣韯討B(tài)地隱藏所有匹配的元素,在隱藏完成后可選地觸發(fā)一個(gè)回調(diào)函數(shù)。
[Ctrl+A 全選 注:引入外部Js需再刷新一下頁面才能執(zhí)行]
您可能感興趣的文章:
- JQuery 寫的個(gè)性導(dǎo)航菜單
- 基于jquery實(shí)現(xiàn)導(dǎo)航菜單高亮顯示(兩種方法)
- jQuery彈性滑動導(dǎo)航菜單實(shí)現(xiàn)思路及代碼
- Jquery實(shí)現(xiàn)帶動畫效果的經(jīng)典二級導(dǎo)航菜單
- 基于jQuery的簡單的列表導(dǎo)航菜單
- jQuery實(shí)現(xiàn)的動態(tài)伸縮導(dǎo)航菜單實(shí)例
- 純CSS打造的導(dǎo)航菜單(附j(luò)query版)
- jQuery三級下拉列表導(dǎo)航菜單代碼分享
- jQuery實(shí)現(xiàn)簡潔的導(dǎo)航菜單效果
- jQuery漸變發(fā)光導(dǎo)航菜單的實(shí)例代碼
- 分享14個(gè)很酷的jQuery導(dǎo)航菜單插件
- jQuery實(shí)現(xiàn)的背景動態(tài)變化導(dǎo)航菜單效果
- 制作jquery遮罩層效果導(dǎo)航菜單代碼分享
- jQuery實(shí)現(xiàn)簡單漂亮的Nav導(dǎo)航菜單效果
相關(guān)文章
從零開始學(xué)習(xí)jQuery (三) 管理jQuery包裝集
在使用jQuery選擇器獲取到j(luò)Query包裝集后, 我們需要對其進(jìn)行操作. 本章首先講解如何動態(tài)的創(chuàng)建元素, 接著學(xué)習(xí)如何管理jQuery包裝集, 比如添加,刪除,切片等.2011-02-02JQuery 動態(tài)生成Table表格實(shí)例代碼
這篇文章主要介紹了JQuery 動態(tài)生成Table表格實(shí)例代碼的相關(guān)資料,這里附有實(shí)現(xiàn)實(shí)例代碼,具有一定的參考價(jià)值,需要的朋友可以參考下2016-12-12jQuery實(shí)現(xiàn)伸展與合攏panel的方法
這篇文章主要介紹了jQuery實(shí)現(xiàn)伸展與合攏panel的方法,可實(shí)現(xiàn)操作div層的平滑收縮與展開的功能,涉及jQuery中next、slideUp、slideDown等方法的使用技巧,非常簡單實(shí)用,需要的朋友可以參考下2015-04-04jquery實(shí)現(xiàn)tab鍵進(jìn)行選擇后enter鍵觸發(fā)click行為
本文主要介紹了jquery鍵盤事件實(shí)現(xiàn)tab鍵進(jìn)行選擇后enter鍵觸發(fā)click行為的方法,這種使用場景為當(dāng)首頁有幾個(gè)鏈接需要選擇的時(shí)候,使用鍵盤就可以進(jìn)行觸發(fā)行為。下面跟著小編一起來看下吧2017-03-03JS+CSS實(shí)現(xiàn)圖片預(yù)加載與背景圖上中下切圖
這篇文章介紹了JS+CSS實(shí)現(xiàn)圖片預(yù)加載與背景圖上中下切圖的方法,文中通過示例代碼介紹的非常詳細(xì)。對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2022-06-06jQuery中RadioButtonList的功能及用法實(shí)例介紹
RadioButtonList的使用想必大家都有所解除,本文為以示例的方式為大家詳細(xì)介紹下其功能及用法,感興趣的朋友可以參考下2013-08-08