仿客齐集首页导航条DIV+CSS+JS [代码实例]
2007-04-26 00:00
1121 查看
作者子鼠
客齐集首页的一个效果, 今天有人问我是怎么写的,于是晚上就又重写了一个; 顺便把那个布局再理一下;
你可以先看一下客齐集首页的效果:http://shanghai.kijiji.cn
我试着不用position:absolute的方法; 但写起来太难了; 后来还是用position:absolute了; 但在客齐集站上的是没有用的;真不知道当时是怎么写出来的;
以下是效果图:
以下是布局部分
以下是CSS部分:CSS还是没有优化的;
以下为JS部分:由于javascript对于我来说太难了;所以可能这部分写的比较烂,但效果是出来了;
以下是用到的四个图:
看下效果吧!
客齐集导航条测试
/*子鼠 www.zishu.cn*/
* {margin:0;padding:0;font-size:12px;font-family:Verdana, Arial, "宋体"; list-style:none;}
body {background: #FFFFCC;margin:100px 0 0 100px;}
#info {border:1px solid #FFCC66;padding:30px;background:#f7f7f7;width:500px;}
#kjj_tag {width:500px;border-bottom:1px solid #CCC; background:url(http://www.zishu.cn/attachments/month_0704/o200742501718.gif) repeat-x left bottom;height:30px;}
#info1,#info2,#info3,#info4,#info5{ border:1px solid #ccc;border-top:none; padding:10px; background:#fff; clear:both; }
h4{ font-weight:normal;float:left;border-right:1px solid #fff;}
.hd {display:none;}
.sw {display:block;}
#info li {float:left;}
#info li a{float:left; display:block; padding:4px 10px 4px 10px; color:#37572E; text-decoration:none}
#info li a:hover{ background:#E9FE70; color:#000}
#info ul { float:left; margin-top:-28px; padding:5px 0; position:absolute}
#info .ha a{ color:#FFF}
#info .ha a:hover{color:#FFF; background:none}
#info .ha .hc:hover{background:url(http://www.zishu.cn/attachments/month_0704/5200742501725.gif) no-repeat center bottom; }
.ha {background:url(http://www.zishu.cn/attachments/month_0704/a20074250170.gif) no-repeat left top;margin-top:-3px;padding-top:3px;}
.hb{ background:url(http://www.zishu.cn/attachments/month_0704/x200742501712.gif) no-repeat right top; margin-top:-3px; padding-top:3px;}
.hc {background:url(http://www.zishu.cn/attachments/month_0704/5200742501725.gif) no-repeat center bottom; height:17px; color:#FFF; font-weight:bold}
热门活动
最新功能
服务承诺
最新成功故事
热贴推荐
子鼠00001客齐集上海
子鼠00002客齐集北京
子鼠00003客齐集呼和浩特
子鼠00004客齐集杭州
子鼠00005客齐集总首页
var k = Math.floor(Math.random()*5+1);
for(i=1; i
客齐集首页的一个效果, 今天有人问我是怎么写的,于是晚上就又重写了一个; 顺便把那个布局再理一下;
你可以先看一下客齐集首页的效果:http://shanghai.kijiji.cn
我试着不用position:absolute的方法; 但写起来太难了; 后来还是用position:absolute了; 但在客齐集站上的是没有用的;真不知道当时是怎么写出来的;
以下是效果图:
以下是布局部分
<div id="info"> <div id="kjj_tag"> </div> <ul> <li id="tag1"><h4><a href="http://www.jb51.net/article/javascript:kijijitag('1');">热门活动</a></h4></li> <li id="tag2"><h4><a href="http://www.jb51.net/article/javascript:kijijitag('2');" >最新功能</a></h4></li> <li id="tag3"><h4><a href="http://www.jb51.net/article/javascript:kijijitag('3');" >服务承诺</a></h4></li> <li id="tag4"><h4><a href="http://www.jb51.net/article/javascript:kijijitag('4');" >最新成功故事</a></h4></li> <li id="tag5"><h4><a href="http://www.jb51.net/article/javascript:kijijitag('5');" >热贴推荐</a></h4></li> </ul> <div id="info1"><a href="http://www.zishu.cn" target="blank">子鼠00001</a></div> <div id="info2"><a href="http://www.zishu.cn" target="blank">子鼠00002</a></div> <div id="info3"><a href="http://www.zishu.cn" target="blank">子鼠00003</a></div> <div id="info4"><a href="http://www.zishu.cn" target="blank">子鼠00004</a></div> <div id="info5"><a href="http://www.zishu.cn" target="blank">子鼠00005</a></div> </div>
以下是CSS部分:CSS还是没有优化的;
<style> /*子鼠 www.zishu.cn*/ * {margin:0;padding:0;font-size:12px;font-family:Verdana, Arial, "宋体"; list-style:none;} body {background: #FFFFCC;margin:100px 0 0 100px;} #info {border:1px solid #FFCC66;padding:30px;background:#f7f7f7;width:500px;} #kjj_tag {width:500px;border-bottom:1px solid #CCC; background:url(taga_c.gif) repeat-x left bottom;height:30px;} #info1,#info2,#info3,#info4,#info5{ border:1px solid #ccc;border-top:none; padding:10px; background:#fff; clear:both; } h4{ font-weight:normal;float:left;border-right:1px solid #fff;} .hd {display:none;} .sw {display:block;} #info li {float:left;} #info li a{float:left; display:block; padding:4px 10px 4px 10px; color:#37572E; text-decoration:none} #info li a:hover{ background:#E9FE70; color:#000} #info ul { float:left; margin-top:-28px; padding:5px 0; position:absolute} #info .ha a{ color:#FFF} #info .ha a:hover{color:#FFF; background:none} #info .ha .hc:hover{background:url(tag_d.gif) no-repeat center bottom; } .ha {background:url(taga_a.gif) no-repeat left top;margin-top:-3px;padding-top:3px;} .hb{ background:url(taga_b.gif) no-repeat right top; margin-top:-3px; padding-top:3px;} .hc {background:url(tag_d.gif) no-repeat center bottom; height:17px; color:#FFF; font-weight:bold} </style>
以下为JS部分:由于javascript对于我来说太难了;所以可能这部分写的比较烂,但效果是出来了;
<script language="javascript"> var k = Math.floor(Math.random()*5+1); for(i=1; i <6; i++){ if( i==k){ document.getElementById("info"+i).className="sw"; document.getElementById("tag"+i).className="ha"; document.getElementById("tag"+i).getElementsByTagName("h4")[0].className="hb"; document.getElementById("tag"+i).getElementsByTagName("a")[0].className="hc"; } else{ document.getElementById("info"+i).className="hd"; } } function kijijitag(tag){ for(i=1; i <6; i++) { if (i==tag) { document.getElementById("info"+i).className="sw"; document.getElementById("tag"+i).className="ha"; document.getElementById("tag"+i).getElementsByTagName("h4")[0].className="hb"; document.getElementById("tag"+i).getElementsByTagName("a")[0].className="hc"; } else{ document.getElementById("info"+i).className="hd"; document.getElementById("tag"+i).className=""; document.getElementById("tag"+i).getElementsByTagName("h4")[0].className=""; document.getElementById("tag"+i).getElementsByTagName("a")[0].className=""; } } } </script>
以下是用到的四个图:
看下效果吧!
客齐集导航条测试
/*子鼠 www.zishu.cn*/
* {margin:0;padding:0;font-size:12px;font-family:Verdana, Arial, "宋体"; list-style:none;}
body {background: #FFFFCC;margin:100px 0 0 100px;}
#info {border:1px solid #FFCC66;padding:30px;background:#f7f7f7;width:500px;}
#kjj_tag {width:500px;border-bottom:1px solid #CCC; background:url(http://www.zishu.cn/attachments/month_0704/o200742501718.gif) repeat-x left bottom;height:30px;}
#info1,#info2,#info3,#info4,#info5{ border:1px solid #ccc;border-top:none; padding:10px; background:#fff; clear:both; }
h4{ font-weight:normal;float:left;border-right:1px solid #fff;}
.hd {display:none;}
.sw {display:block;}
#info li {float:left;}
#info li a{float:left; display:block; padding:4px 10px 4px 10px; color:#37572E; text-decoration:none}
#info li a:hover{ background:#E9FE70; color:#000}
#info ul { float:left; margin-top:-28px; padding:5px 0; position:absolute}
#info .ha a{ color:#FFF}
#info .ha a:hover{color:#FFF; background:none}
#info .ha .hc:hover{background:url(http://www.zishu.cn/attachments/month_0704/5200742501725.gif) no-repeat center bottom; }
.ha {background:url(http://www.zishu.cn/attachments/month_0704/a20074250170.gif) no-repeat left top;margin-top:-3px;padding-top:3px;}
.hb{ background:url(http://www.zishu.cn/attachments/month_0704/x200742501712.gif) no-repeat right top; margin-top:-3px; padding-top:3px;}
.hc {background:url(http://www.zishu.cn/attachments/month_0704/5200742501725.gif) no-repeat center bottom; height:17px; color:#FFF; font-weight:bold}
热门活动
最新功能
服务承诺
最新成功故事
热贴推荐
子鼠00001客齐集上海
子鼠00002客齐集北京
子鼠00003客齐集呼和浩特
子鼠00004客齐集杭州
子鼠00005客齐集总首页
var k = Math.floor(Math.random()*5+1);
for(i=1; i
相关文章推荐
- 仿客齐集首页导航条DIV+CSS+JS [代码实例]
- JS+CSS实现鼠标经过弹出一个DIV框完整实例(带缓冲动画渐变效果)
- css+div宽度自适应实例代码
- 动态加载js、css的实例代码
- DIV+CSS网页另类上下布局的实例代码
- CSS网页实例 利用box-sizing实现div仿框架结构实现代码
- 一个自动居中的导航条实例与相关问题 DIV+CSS
- DIV+CSS高度自适应方法网页代码实例
- JS+CSS实现带有碰撞缓冲效果的竖向导航条代码
- JS当前页面登录注册框,固定DIV,底层阴影的实例代码
- 用js实现的DIV+CSS编辑器代码
- div+css布局的图片连续滚动js实现代码
- CSS+DIV网页布局(黄冈网校首页布局)示例代码
- js+html+css实现鼠标移动div实例
- 美工代码注意事项(html+div+css+js)
- 完美的js div拖拽实例代码
- js+css position:relative;absolute;仿大众点评网首页 左边菜单效果[实例]
- div+css+js实现无缝滚动类似marquee无缝滚动代码
- 纯css+js下拉菜单实例代码
- DIV+CSS+JS实现图片<ul><li></li></ul>无缝滚动代码