DIV CSS JS仿kijiji導(dǎo)航條_DIV+CSS實(shí)例
教程Tag:暫無Tag,歡迎添加,賺取U幣!
客齊集首頁的一個(gè)效果, 今天有人問我是怎么寫的,于是晚上就又重寫了一個(gè); 順便把那個(gè)布局再理一下;
你可以先看一下客齊集首頁的效果:http://shanghai.kijiji.cn
我試著不用position:absolute的方法; 但寫起來太難了; 后來還是用position:absolute了; 但在客齊集站上的是沒有用的;真不知道當(dāng)時(shí)是怎么寫出來的;
以下是效果圖:
以下是布局部分:
以下是CSS部分:(CSS還沒有優(yōu)化)
以下為JS部分:由于javascript對于我來說太難了;所以可能這部分寫的比較爛,但效果是出來了;
以下是用到的四個(gè)圖:
看下效果:
[ 可先修改部分代碼 再運(yùn)行查看效果 ]
非凡說明:
1、CSS部分不是很清楚,因?yàn)閷懙奈叶加悬c(diǎn)暈了;
2、五個(gè)TAG是隨機(jī)換的;
3、JS部分還可以再精簡一些,但要有CSS支持;
本文作者:zishu
你可以先看一下客齊集首頁的效果:http://shanghai.kijiji.cn
我試著不用position:absolute的方法; 但寫起來太難了; 后來還是用position:absolute了; 但在客齊集站上的是沒有用的;真不知道當(dāng)時(shí)是怎么寫出來的;
以下是效果圖:
以下是布局部分:
示例代碼 [m.dounai2.com]
<div id="info">
<div id="kjj_tag"> </div>
<ul>
<li id="tag1"><h4><a href="javascript:kijijitag('1');">熱門活動</a></h4></li>
<li id="tag2"><h4><a href="javascript:kijijitag('2');" >最新功能</a></h4></li>
<li id="tag3"><h4><a href="javascript:kijijitag('3');" >服務(wù)承諾</a></h4></li>
<li id="tag4"><h4><a href="javascript:kijijitag('4');" >最新成功故事</a></h4></li>
<li id="tag5"><h4><a href="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>
<div id="kjj_tag"> </div>
<ul>
<li id="tag1"><h4><a href="javascript:kijijitag('1');">熱門活動</a></h4></li>
<li id="tag2"><h4><a href="javascript:kijijitag('2');" >最新功能</a></h4></li>
<li id="tag3"><h4><a href="javascript:kijijitag('3');" >服務(wù)承諾</a></h4></li>
<li id="tag4"><h4><a href="javascript:kijijitag('4');" >最新成功故事</a></h4></li>
<li id="tag5"><h4><a href="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還沒有優(yōu)化)
示例代碼 [m.dounai2.com]
/*子鼠 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}
* {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}
以下為JS部分:由于javascript對于我來說太難了;所以可能這部分寫的比較爛,但效果是出來了;
示例代碼 [m.dounai2.com]
<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>
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>
以下是用到的四個(gè)圖:
看下效果:
代碼調(diào)試框 [m.dounai2.com]
[ 可先修改部分代碼 再運(yùn)行查看效果 ]
非凡說明:
1、CSS部分不是很清楚,因?yàn)閷懙奈叶加悬c(diǎn)暈了;
2、五個(gè)TAG是隨機(jī)換的;
3、JS部分還可以再精簡一些,但要有CSS支持;
本文作者:zishu
相關(guān)DIV+CSS實(shí)例:
- 固定div容器的寬高,圖片居中(圖片不限制大小)
- 用css制作有滾動條的居中彈出框
- 鼠標(biāo)指住(hover)變色的按鈕演示demo
- 10個(gè)很酷的涂鴉風(fēng)格國外網(wǎng)店設(shè)計(jì)展示
- jquery模擬瀏覽器滾動條效果
- 仿谷歌google的搜索框下拉提示列表效果
- JS顯示網(wǎng)頁最后更新時(shí)間
- CSS技巧:text-indent隱藏文字(以圖換字)
- CSS實(shí)例:三列自適應(yīng)等高且中列寬度自適應(yīng)
- DivCSS布局實(shí)例:很實(shí)用的圖文混排CSS列表-富有語義
- DivCSS實(shí)例:CSS菜單Flash效果用圖片模擬實(shí)現(xiàn)
- DivCSS布局實(shí)例用dldtdd來制作列表
DIV+CSS實(shí)例Rss訂閱Div+Css教程搜索
DIV+CSS實(shí)例推薦
- CSS JavaScript打造鼠標(biāo)懸停圖片漸顯效果!
- CSS實(shí)例:kijiji社區(qū)頭像CSS效果
- 用css網(wǎng)站布局之十步實(shí)錄!(三)
- CSS實(shí)例:三列自適應(yīng)等高且中列寬度自適應(yīng)
- CSS實(shí)例:Unobtrusive頁簽切換符合Web標(biāo)準(zhǔn)具有html語義
- CSS布局實(shí)例:margin優(yōu)化的一種思路
- CSS去除表格td默認(rèn)間距及制作1px細(xì)線表格
- CSS實(shí)例:區(qū)分IE6、IE7、FF對HR解釋的CSShack
- CSS實(shí)例:無懈可擊的CSS圓角技術(shù)!
- 仿谷歌google的搜索框下拉提示列表效果
猜你也喜歡看這些
- 菜單運(yùn)用li標(biāo)簽橫向排列自適應(yīng)寬度
- DIVCSS網(wǎng)頁布局:HTML結(jié)構(gòu)化DIVCSS網(wǎng)頁布局入門指南
- 如何在CSS中寫腳本實(shí)現(xiàn)交互效果?
- WEB2.0標(biāo)準(zhǔn)教程:第十天自適應(yīng)高度
- position:relativeabsolute無法沖破
- 最基本的ulli構(gòu)成的橫向?qū)Ш讲藛?本站頂部所示)
- 超鏈接訪問過后hover樣式就不出現(xiàn)的問題
- 深入CSS2.0結(jié)構(gòu),再談div、span的困惑!
- DIV元素和SPAN元素的區(qū)別和應(yīng)用
- WEB2.0標(biāo)準(zhǔn)教程:第三天定義語言編碼
- 相關(guān)鏈接:
- 教程說明:
DIV+CSS實(shí)例-DIV CSS JS仿kijiji導(dǎo)航條。