国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

JavaScript+CSS實現仿天貓側邊網頁菜單效果

2019-11-20 11:43:29
字體:
來源:轉載
供稿:網友

本文實例講述了JavaScript+CSS實現仿天貓側邊網頁菜單效果。分享給大家供大家參考。具體如下:

這是一款自己寫的仿天貓的菜單效果,二級分類的功能已經實現,但沒有美化,留著用的朋友自己完善吧,JS功能已經實現,鼠標移在主分類上,二級分類向右伸出展開,目前淘寶網、天貓購物、京東都在用的導航菜單特效,測試時候請先點擊一下菜單,主菜單就顯示出來了。

運行效果截圖如下:

在線演示地址如下:

http://demo.VeVB.COm/js/2015/js-css-ftamil-web-menu-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><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>仿天貓側邊網頁菜單</title><style type="text/css">*{margin:0; padding:0;}body{ font-size:14px; font-family:"宋體";}h1, h2, h3{ font-size:14px; font-weight:normal;}li{ list-style:none;}a{ color:#333; text-decoration:none;}#nav{ width:202px; height:35px; background:#C00; margin:50px 0 0 20px;}#nav h1{ padding-left:17px; line-height:35px; color:#fff; margin-right:17px;}#box{ width:200px; border:1px solid #B00; border-top:none; margin-left:20px; display:none;}#subnav{width:200px;}#subnav .list{ width:200px; height:30px;}#subnav .list h2{ width:160px; height:30px; padding-left:30px; line-height:30px; margin-right:10px;}#subnav .list a:hover, #subnav .active a:hover{ color:#900; font-weight:bold;}#subnav .active{ width:200px; height:30px; border-bottom:1px solid #b00; border-top:1px solid #b00; position:relative;}#subnav .active h2{ width:170px; height:30px; padding-left:30px; line-height:30px; background:#fff; position:absolute; left:1px; top:0; z-index:4;}#subnav .list_nav{ width:500px; overflow:hidden; border:1px solid #b00; position:absolute; left:200px; top:-1px; z-index:3; display:none;}</style><script type="text/javascript">window.onload=function(){ var oNav=document.getElementById('nav'); var oBox=document.getElementById('box'); var oSubnav=document.getElementById('subnav'); var aLi=oSubnav.getElementsByTagName('li'); var i=0; oNav.onclick=function() {  if(oBox.style.display=='block')  {   oBox.style.display='none';  }  else  {   oBox.style.display='block';  } } for(i=0;i<aLi.length;i++) {  if(aLi[i].className=='list')  {   aLi[i].onmousemove=function()   {    for(i=0;i<aLi.length;i++)    {     var aDivList=this.getElementsByTagName('div')[0];     aDivList.style.display='block';     this.className='active';    }   }   aLi[i].onmouseout=function()   {    for(i=0;i<aLi.length;i++)    {     var aDivList=this.getElementsByTagName('div')[0];     aDivList.style.display='none';     this.className='list';      }   }  } }};</script></head><body><div id="nav"><h1>所有商品分類</h1></div><div id="box"> <ul id="subnav">  <li class="list">   <h2><a href="#">服飾內衣、鞋靴運動</a></h2>   <div class="list_nav">    <ul>     <li>1</li>     <li>1</li>     <li>1</li>     <li>1</li>    </ul>   </div>  </li>  <li class="list">   <h2><a href="#">電子商品</a></h2>   <div class="list_nav">    <ul>     <li>222</li>     <li>2222</li>     <li>2222</li>     <li>22222</li>    </ul>   </div>  </li>  <li class="list">   <h2><a href="#">服飾內衣、鞋靴運動</a></h2>   <div class="list_nav">    <ul>     <li>3333</li>     <li>3333</li>     <li>3333</li>     <li>3333</li>    </ul>   </div>  </li>  <li class="list">   <h2><a href="#">服飾內衣、鞋靴運動</a></h2>   <div class="list_nav">    <ul>     <li>1</li>     <li>1</li>     <li>1</li>     <li>1</li>    </ul>   </div>  </li> </ul></div></body></html>

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

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 四子王旗| 特克斯县| 安泽县| 寿光市| 乌拉特中旗| 凤台县| 涿鹿县| 西畴县| 二连浩特市| 中江县| 金溪县| 巫山县| 新民市| 那曲县| 额尔古纳市| 紫阳县| 二连浩特市| 汽车| 鄂伦春自治旗| 株洲市| 凌云县| 城口县| 福海县| 泸溪县| 夹江县| 武邑县| 工布江达县| 伊宁市| 内丘县| 道孚县| 敦化市| 德令哈市| 徐闻县| 钦州市| 永泰县| 进贤县| 铁力市| 吉水县| 通辽市| 阳东县| 新闻|