jquery仿京東導(dǎo)航/仿淘寶商城左側(cè)分類導(dǎo)航下拉菜單效果
更新時間:2013年04月24日 16:19:38 作者:
jquery實(shí)現(xiàn)下拉菜單效果,jquery寫的仿京東導(dǎo)航菜單,一個經(jīng)典的左側(cè)多級導(dǎo)航菜單,學(xué)會了可以任意改變布局,感興趣的朋友可以參考下哈,希望對你有所幫助
在網(wǎng)站建設(shè)中,特別是做商城和產(chǎn)品網(wǎng)站,通常會用到導(dǎo)航彈出菜單,像是jquery寫的仿京東導(dǎo)航菜單,一個經(jīng)典的左側(cè)多級導(dǎo)航菜單,學(xué)會了可以任意改變布局。京東菜單已經(jīng)有不少JS前端愛好者仿寫過,今天螞蟻網(wǎng)絡(luò)重新與大家分享一款仿京東商城的商品多級分類菜單,精簡版代碼
先看下jquery仿京東導(dǎo)航效果:


前端html代碼如下:
<ul>
<li><a href="#">baidu</a></li>
<div class="tips">
<p><a >baidu</a></p>
</div>
<li>goolge</li>
<div class="tips">
<p><a >google</a></p>
</div>
<li>yahoo</li>
<div class="tips">
<p><a >yahoo</a></p>
</div>
<li>microsoft</li>
<div class="tips">
<p><a >microsoft</a></p>
</div>
</ul>
<style type="text/css">
html{color:#666;background:#FFF;}
body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,i,fieldset,legend,input,textarea,p,blockquote,th,td{margin:0;padding:0;}
body{font:12px/1.3 arial,helvetica,clean,sans-serif,\5b8b\4f53;}
h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal}
table{border-collapse:collapse;border-spacing:0;}
img{border:none;}
a{text-decoration:none; color:#666;}
a:hover{text-decoration:underline; color:#FF6600;}
ul,li{list-style-type:none;}
q:before,q:after{content:'';}
sup{vertical-align:text-top;}sub{vertical-align:text-bottom;}
/* All reset */
body{ margin:100px;}
ul li{line-height:30px; border:1px solid #E5D1A1; text-align:center; margin-top:-1px; width:200px; background:#FFFDD2; position:relative; z-index:1;}
.tips{position:absolute; width:150px; height:150px; border:1px solid #E5D1A1; background:#fff; z-index:2; display:none;}
</style>
js代碼:
<script type="text/javascript">
$(function(){
$("ul li").each(function(index){
$(this).mouseover(function(){
var obj=$(this).offset();
var xobj=obj.left+190+"px";
var yobj=obj.top-50+"px";
$(this).css({"width":"190px","z-index":"9999","border-right":"none","background":"#fff"});
$("ul > div:eq("+index+")").css({"left":xobj,"top":yobj}).show();
}).mouseout(function(){
$("ul > .tips").hide();
$(this).css({"width":"200px","z-index":"1","border":"1px solid #E5D1A1","background":"#FFFDD2"})
})
})
$("div").each(function(){
$(this).mouseover(function(){
$(this).prev("li").css({"width":"190px","z-index":"9999","border-right":"none","background":"#fff"})
$(this).show();
}).mouseout(function(){
$(this).hide();
$(this).prev("li").css({"width":"200px","z-index":"1","border":"1px solid #E5D1A1","background":"#FFFDD2"});
})
})
})
</script>
效果圖如下,


jQuery仿京東左側(cè)菜單效果,適合商城產(chǎn)品導(dǎo)航,這里沒有做的那么細(xì),只是使用CSS結(jié)合jQuery完成了菜單的簡單效果,如果需要美化,請您在實(shí)際應(yīng)用中自己搞一下吧,兼容性非常不錯的,歡迎大家使用。
先看下jquery仿京東導(dǎo)航效果:


前端html代碼如下:
復(fù)制代碼 代碼如下:
<ul>
<li><a href="#">baidu</a></li>
<div class="tips">
<p><a >baidu</a></p>
</div>
<li>goolge</li>
<div class="tips">
<p><a >google</a></p>
</div>
<li>yahoo</li>
<div class="tips">
<p><a >yahoo</a></p>
</div>
<li>microsoft</li>
<div class="tips">
<p><a >microsoft</a></p>
</div>
</ul>
<style type="text/css">
html{color:#666;background:#FFF;}
body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,i,fieldset,legend,input,textarea,p,blockquote,th,td{margin:0;padding:0;}
body{font:12px/1.3 arial,helvetica,clean,sans-serif,\5b8b\4f53;}
h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal}
table{border-collapse:collapse;border-spacing:0;}
img{border:none;}
a{text-decoration:none; color:#666;}
a:hover{text-decoration:underline; color:#FF6600;}
ul,li{list-style-type:none;}
q:before,q:after{content:'';}
sup{vertical-align:text-top;}sub{vertical-align:text-bottom;}
/* All reset */
body{ margin:100px;}
ul li{line-height:30px; border:1px solid #E5D1A1; text-align:center; margin-top:-1px; width:200px; background:#FFFDD2; position:relative; z-index:1;}
.tips{position:absolute; width:150px; height:150px; border:1px solid #E5D1A1; background:#fff; z-index:2; display:none;}
</style>
js代碼:
復(fù)制代碼 代碼如下:
<script type="text/javascript">
$(function(){
$("ul li").each(function(index){
$(this).mouseover(function(){
var obj=$(this).offset();
var xobj=obj.left+190+"px";
var yobj=obj.top-50+"px";
$(this).css({"width":"190px","z-index":"9999","border-right":"none","background":"#fff"});
$("ul > div:eq("+index+")").css({"left":xobj,"top":yobj}).show();
}).mouseout(function(){
$("ul > .tips").hide();
$(this).css({"width":"200px","z-index":"1","border":"1px solid #E5D1A1","background":"#FFFDD2"})
})
})
$("div").each(function(){
$(this).mouseover(function(){
$(this).prev("li").css({"width":"190px","z-index":"9999","border-right":"none","background":"#fff"})
$(this).show();
}).mouseout(function(){
$(this).hide();
$(this).prev("li").css({"width":"200px","z-index":"1","border":"1px solid #E5D1A1","background":"#FFFDD2"});
})
})
})
</script>
效果圖如下,


jQuery仿京東左側(cè)菜單效果,適合商城產(chǎn)品導(dǎo)航,這里沒有做的那么細(xì),只是使用CSS結(jié)合jQuery完成了菜單的簡單效果,如果需要美化,請您在實(shí)際應(yīng)用中自己搞一下吧,兼容性非常不錯的,歡迎大家使用。
您可能感興趣的文章:
- jQuery實(shí)現(xiàn)菜單欄導(dǎo)航效果
- 基于jQuery實(shí)現(xiàn)左側(cè)菜單欄可折疊功能
- 最常見的左側(cè)分類菜單欄jQuery實(shí)現(xiàn)代碼
- 基于jquery實(shí)現(xiàn)導(dǎo)航菜單高亮顯示(兩種方法)
- jQuery 實(shí)現(xiàn)側(cè)邊浮動導(dǎo)航菜單效果
- jquery實(shí)現(xiàn)點(diǎn)擊向下展開菜單項(xiàng)(伸縮導(dǎo)航)效果
- jQuery實(shí)現(xiàn)的導(dǎo)航下拉菜單效果示例
- JQuery 寫的個性導(dǎo)航菜單
- jQuery仿京東商城樓梯式導(dǎo)航定位菜單
- jquery實(shí)現(xiàn)網(wǎng)頁左側(cè)導(dǎo)航菜單欄
相關(guān)文章
jQuery實(shí)現(xiàn)的彈幕效果完整實(shí)例
這篇文章主要介紹了jQuery實(shí)現(xiàn)的彈幕效果,結(jié)合完整實(shí)例形式分析了jQuery通過結(jié)合時間函數(shù)控制輸入文字與樣式的漸變實(shí)現(xiàn)彈幕效果,需要的朋友可以參考下2017-09-09
jQuery實(shí)現(xiàn)checkbox即點(diǎn)即改批量刪除及中間遇到的坑
這篇文章主要介紹了jQuery實(shí)現(xiàn)checkbox即點(diǎn)即改批量刪除及中間遇到的坑,非常不錯,具有參考借鑒價值,需要的朋友可以參考下2017-11-11
利用jquery實(shí)現(xiàn)下拉框的禁用與啟用
本文主要介紹了jquery實(shí)現(xiàn)下拉框的禁用與啟用的具體代碼。代碼清晰,容易理解。有需要的朋友可以參考下,希望會對大家有所幫助2016-12-12
jquery獲取當(dāng)前點(diǎn)擊的元素的五種方法介紹
我們可以使用$(this)方法獲取事件處理函數(shù)內(nèi)部的當(dāng)前元素,也可以使用e.target方法在外部獲取當(dāng)前元素,此外,我們還介紹了parent()方法和find()方法獲取當(dāng)前元素的父元素或子元素,以及closest()方法獲取當(dāng)前元素最近的祖先元素2023-08-08
jQuery實(shí)現(xiàn)調(diào)整表格單列順序完整實(shí)例
這篇文章主要介紹了jQuery實(shí)現(xiàn)調(diào)整表格單列順序的方法,結(jié)合完整實(shí)例形式分析了jQuery響應(yīng)鼠標(biāo)事件及動態(tài)操作頁面元素的相關(guān)技巧,具有一定參考借鑒價值,需要的朋友可以參考下2016-06-06
jQuery(1.6.3) 中css方法對浮動的實(shí)現(xiàn)缺陷分析
JavaScript中設(shè)置元素的浮動屬性(float),標(biāo)準(zhǔn)瀏覽器使用cssFloat,IE舊版本使用styleFloat。2011-09-09

