CSS导航菜单(仿淘宝首页导航条布局效果)


一直以来,人们都认为淘宝的导航条不错,更有很多网站效仿;今天就当作个练习,作一下这个导航条;
以下效果应用的图片共2张,如果只用1张效果不太好,特别是圆角部分。我大致看了一下淘宝现在的导航条,分别用了十几张图片,并不是用以下这个方法作的,如果你有兴趣现在可以上淘宝网看一下,鼠标移上去的图片不能立刻显示,这样的效果不是很理想。
这次我试着把显示的效果图和鼠标移上去的图合成一个了,这样鼠标移上去就不用再加载一次这个图了,可以解决以前鼠标移上去还得等一会的问题。(测试后的效果似乎还真的可以)
测试代码,CSS和内容都没有优化;

CSS代码如下:
Example Source Code [www.52css.com] 【CSS导航菜单(仿淘宝首页导航条布局效果)】
/* www.zishu.cn 子鼠*/
body{ font-size:12px; text-align:center; margin-top:30px; font-family:Verdana; }
div,img{margin:0; padding:0; border:0; }
ul,li{list-style-type: none; margin:0; padding:0; float:left; }
#info{ margin-left:auto; margin-right:auto; width:760px; text-align:left; }
#new{ margin-top:-12px; position: absolute; margin-left:-12px; }
#nav{ height:30px; width:610px; margin-left:auto; margin-right:auto; }
#nav li{margin-left:1px; height:30px; }
#nav li a{ display:block; float:left; text-decoration:none; background-image: url(attachments/month_0605/r200652134132.gif); background-repeat: no-repeat; display:block; background-position:left top; }
#nav a span{cursor:hand; color:#000; background-image: url(attachments/month_0605/v200652134115.gif); background-repeat: no-repeat; display:block; background-position: right top; padding:7px 10px 6px 10px; float:left; }
#nav li a:active,#nav li a:hover {margin-top:0px; }
#nav lia:active span,#nav li a:hover span {padding:10px 10px 6px 10px; margin-top:0px; display:block; color:#FFF; }
#zishu01 a:link,#zishu01 a:visited {background-position: 0px -27px; }
#zishu01 a:link span,#zishu01 a:visited span{background-position:right -27px; padding:10px 10px 6px 10px; margin-top:0; color:#FFF; font-weight:bold; }
#zishu02 a,#zishu03 a,#zishu04 a,#zishu05 a,#zishu06 a,#zishu07 a,#zishu08 a,#zishu09 a,#zishu10 a,#zishu11 a{margin-top:3px; }
#zishu02 a:active,#zishu02 a:hover {background-position: 0px -57px; }
#zishu02 a:active span,#zishu02 a:hover span{background-position:right -57px; }
#zishu03 a:active,#zishu03 a:hover {background-position: 0px -87px; }
#zishu03 a:active span,#zishu03 a:hover span{background-position:right -87px; }
#zishu04 a:active,#zishu04 a:hover {background-position: 0px -117px; }
#zishu04 a:active span,#zishu04 a:hover span{background-position:right -117px; }
#zishu05 a:active,#zishu05 a:hover {background-position: 0px -147px; }
#zishu05 a:active span,#zishu05 a:hover span{background-position:right -147px; }
#zishu06 a:active,#zishu06 a:hover {background-position: 0px -177px; }
#zishu06 a:active span,#zishu06 a:hover span{background-position:right -177px; }
#zishu07 a:active,#zishu07 a:hover {background-position: 0px -207px; }
#zishu07 a:active span,#zishu07 a:hover span{background-position:right -207px; }
#zishu08 a:active,#zishu08 a:hover {background-position: 0px -237px; }
#zishu08 a:active span,#zishu08 a:hover span{background-position:right -237px; }
#zishu09 a:active,#zishu09 a:hover {background-position: 0px -267px; }
#zishu09 a:active span,#zishu09 a:hover span{background-position:right -267px; }
#zishu10 a:active,#zishu10 a:hover {background-position: 0px -297px; }
#zishu10 a:active span,#zishu10 a:hover span{background-position:right -297px; }
#zishu11 a:link span,#zishu11 a:visited span{color:#FF6600; }
#zishu11 a:active,#zishu11 a:hover {background-position: 0px -327px; }
#zishu11 a:active span,#zishu11 a:hover span{background-position:right -327px; }
#menu{ width:760px; height:26px; background:#FF9900; }
#r1{border-top: 0px; border-bottom: 0px; border-left:3px solid #fff; border-right:3px solid #fff; height:1px; overflow:hidden; }
#r2{border-top: 0px; border-bottom: 0px; border-left:2px solid #fff; border-right:2px solid #fff; height:1px; overflow:hidden; }
#r3{border-top: 0px; border-bottom: 0px; border-left:1px solid #fff; border-right:1px solid #fff; height:1px; overflow:hidden; }




  • 首页

  • 数码通讯

  • 女人

  • 男人

  • 家居

  • 书籍音像

  • 运动

  • 游戏

  • 宠物

  • 香港街

  • 淘宝商城

  • CSS导航菜单(仿淘宝首页导航条布局效果)
    文章图片










仿淘宝网首页导航条效果 转载请注明出处 子鼠 www.zishu.cn 2006-05-21 凌晨03:05分



全部代码




TAO BAO TEST 2 - 锐客网

/* www.zishu.cn 子鼠*/
body{ font-size:12px; text-align:center; margin-top:30px; font-family:Verdana; }
div,img{margin:0; padding:0; border:0; }
ul,li{list-style-type: none; margin:0; padding:0; float:left; }
#info{ margin-left:auto; margin-right:auto; width:760px; text-align:left; }
#new{ margin-top:-12px; position: absolute; margin-left:-12px; }
#nav{ height:30px; width:610px; margin-left:auto; margin-right:auto; }
#nav li{margin-left:1px; height:30px; }
#nav li a{ display:block; float:left; text-decoration:none; background-image: url( http://www.zishu.cn/attachments/month_0605/r200652134132.gif); background-repeat: no-repeat; display:block; background-position:left top; }
#nav a span{cursor:hand; color:#000; background-image: url( http://www.zishu.cn/attachments/month_0605/v200652134115.gif); background-repeat: no-repeat; display:block; background-position: right top; padding:7px 10px 6px 10px; float:left; }
#nav li a:active,#nav li a:hover {margin-top:0px; }
#nav li a:active span,#nav li a:hover span {padding:10px 10px 6px 10px; margin-top:0px; display:block; color:#FFF; }
#zishu01 a:link,#zishu01 a:visited {background-position: 0px -27px; }
#zishu01 a:link span,#zishu01 a:visited span{background-position:right -27px; padding:10px 10px 6px 10px; margin-top:0; color:#FFF; font-weight:bold; }
#zishu02 a,#zishu03 a,#zishu04 a,#zishu05 a,#zishu06 a,#zishu07 a,#zishu08 a,#zishu09 a,#zishu10 a,#zishu11 a{margin-top:3px; }
#zishu02 a:active,#zishu02 a:hover {background-position: 0px -57px; }
#zishu02 a:active span,#zishu02 a:hover span{background-position:right -57px; }
#zishu03 a:active,#zishu03 a:hover {background-position: 0px -87px; }
#zishu03 a:active span,#zishu03 a:hover span{background-position:right -87px; }
#zishu04 a:active,#zishu04 a:hover {background-position: 0px -117px; }
#zishu04 a:active span,#zishu04 a:hover span{background-position:right -117px; }
#zishu05 a:active,#zishu05 a:hover {background-position: 0px -147px; }
#zishu05 a:active span,#zishu05 a:hover span{background-position:right -147px; }
#zishu06 a:active,#zishu06 a:hover {background-position: 0px -177px; }
#zishu06 a:active span,#zishu06 a:hover span{background-position:right -177px; }
#zishu07 a:active,#zishu07 a:hover {background-position: 0px -207px; }
#zishu07 a:active span,#zishu07 a:hover span{background-position:right -207px; }
#zishu08 a:active,#zishu08 a:hover {background-position: 0px -237px; }
#zishu08 a:active span,#zishu08 a:hover span{background-position:right -237px; }
#zishu09 a:active,#zishu09 a:hover {background-position: 0px -267px; }
#zishu09 a:active span,#zishu09 a:hover span{background-position:right -267px; }
#zishu10 a:active,#zishu10 a:hover {background-position: 0px -297px; }
#zishu10 a:active span,#zishu10 a:hover span{background-position:right -297px; }
#zishu11 a:link span,#zishu11 a:visited span{color:#FF6600; }
#zishu11 a:active,#zishu11 a:hover {background-position: 0px -327px; }
#zishu11 a:active span,#zishu11 a:hover span{background-position:right -327px; }
#menu{ width:760px; height:26px; background:#FF9900; }
#r1{border-top: 0px; border-bottom: 0px; border-left:3px solid #fff; border-right:3px solid #fff; height:1px; overflow:hidden; }
#r2{border-top: 0px; border-bottom: 0px; border-left:2px solid #fff; border-right:2px solid #fff; height:1px; overflow:hidden; }
#r3{border-top: 0px; border-bottom: 0px; border-left:1px solid #fff; border-right:1px solid #fff; height:1px; overflow:hidden; }






  • 首页

  • 数码通讯

  • 女人

  • 男人

  • 家居

  • 书籍音像

  • 运动

  • 游戏

  • 宠物

  • 香港街

  • 淘宝商城

  • CSS导航菜单(仿淘宝首页导航条布局效果)
    文章图片










仿淘宝网首页导航条效果 转载请注明出处 子鼠 www.zishu.cn 2006-05-21 凌晨03:05分







    推荐阅读