分享
 
 
 

斜体样式的导航条

王朝other·作者佚名  2006-11-24
窄屏简体版  字體: |||超大  

<!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=gb2312" />

<title>无标题文档</title>

<link href="http://www.happyshow.org/sample/20060615/css/main.css" rel="stylesheet" type="text/css">

<link href="http://www.happyshow.org/sample/20060615/css/class.css" rel="stylesheet" type="text/css">

<script src="http://www.happyshow.org/sample/20060615/nav.js" type="text/javascript"></script>

<script type="text/javascript">

var selectindex = 0; //预设项目

var subclass = new Array()

subclass[0] = "<ol><li>·电影</li><li>·餐厅</li><li>·演出</li></ol>";

subclass[1] = "<ol><li>·项链</li><li>·戒指</li><li>·耳环</li></ol>"

subclass[2] = "<ol><li>·吃饭</li><li>·旅游</li></ol>"

subclass[3] = "<ol><li>·万年历</li><li>·我的生日</li><li>·她的生日</li></ol>"

subclass[4] = "<ol><li>·金牛座</li><li>·射手座</li><li>·蝎子座</li><li>·水瓶座</li></ol>"

</script>

</head>

<body onload="preset()">

<div id="con">

<div id="logo">

<img src="http://www.happyshow.org/sample/20060615/images/logo1.gif" width="94" height="75" border="0" align="bottom" />

<img src="http://www.happyshow.org/sample/20060615/images/logo2.gif" width="108" height="63" border="0" align="bottom" style="margin-top:12px;"/>

<div id="search">

<input name="userpass2" type="text" class="inputbox1" id="userpass2" /><img src="http://www.happyshow.org/sample/20060615/images/searchbutton.gif" width="31" height="18" /></div>

<div id="nav" >

<ul id="itemlist" onmouseout="recover()">

<li><a href="http://www.happyshow.org/sample/20060615/index.html"><span onmouseover="focusthis(this)" class="style0">约会安排</span></a></li>

<li><a href="http://www.happyshow.org/sample/20060615/index2.html"><span onmouseover="focusthis(this)" class="style0">礼物安排</span></a></li>

<li><a href="#"><span onmouseover="focusthis(this)" class="style0">话题安排</span></a></li>

<li><a href="#"><span onmouseover="focusthis(this)" class="style0">日历</span></a></li>

<li><a href="#"><span onmouseover="focusthis(this)" class="style0">测试星座</span></a></li>

<li><a href="#"><span style="width:15px;padding:0px" class="style0"> </span></a></li>

</ul>

</div>

</div>

<div id="subclass"> </div>

<div id="content" onmouseover="recover()">

我的博客:<br />

<a href="http://www.happyshow.org" target="_blank">http://www.happyshow.org</a><br>

<br />

<br />

<br />

导航条的三种状态:<br /><br />

<h5 class="style0">style0</h5>

<h5 class="style1">style1</h5>

<h5 class="style2">style2</h5>

</div>

</div>

</body>

</html>

[Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]

已经封装成 js 文件的代码:

// JavaScript Document

function preset()

{

document.getElementById("itemlist").childNodes[selectindex].firstChild.firstChild.className="style1";

document.getElementById("itemlist").childNodes[selectindex+1].childNodes[0].childNodes[0].className="style2";

innersubclass();

}

function focusthis(obj)

{

clearselect();

obj.className = "style1";

obj.parentNode.parentNode.nextSibling.firstChild.firstChild.

className="style2";

innersubclass(obj);

}

function innersubclass(obj)

{

if (obj==null)

{

document.getElementById("subclass").innerHTML = subclass[selectindex];

}else

{

for(i=0; i<obj.parentNode.parentNode.parentNode.childNodes.length;i++)

{

if(obj == document.getElementById("itemlist").childNodes[i].firstChild.firstChild)

{

document.getElementById("subclass").innerHTML = subclass[i];

}

}

}

}

function recover()

{

clearselect();

preset();

innersubclass();

}

function clearselect()

{

for (i=0; i<document.getElementById("itemlist").childNodes.length; i++)

{

document.getElementById("itemlist").childNodes[i].firstChild.firstChild.className="style0";

}

}

在代码编写过程中,发现 Firefox 对 DOM 解释和 IE 对 DOM 的解释差别较大。虽然上面的代码也兼容ff,但实现的方法不太标准,近期需要补习一下 FF 下的DOM。

目前此效果仅能应用于网站导航条,如果要做成斜体的选项卡效果,还需要调整一下代码,但估计不用重写了,呵呵

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有