导航菜单 标签切换
使用的时候要引入jquery.js库
效果图:
?
?
<scirpt type="text/javascript" href="/js/jquery.js"></scirpt>
<style type="text/css">
ul{color:#fff5f5;display:block;margin:0;padding:0}
?
.main{list-style-type:none;display:block}
.main li{float:left;border:1px solid #858585;width:150px;height:24px;font-size:24px;margin:0 2px;text-align:center;padding:10px 0;display:block;background-color:#F0E5DA;vertical-align:middle;position:relative}
.main li a{text-decoration:none;color:#000}
.main li:hover {background-color:#CD0000;color:#FFF5F5}
.main li .innerdiv{position:relative;paddint-top:10px;border:1px solid #858585;width:461px;height:300px;display:none;top:12px;}
.main li .innerdiv .innerspan {color:#000;padding:2px;cursor:pointer;width:150px;margin:0px 5px;border:1px solid #858585;border-top:0;display:block;background-color:#FFF6CC;}
.main li .innerdiv .borderline{width:155px;height:192px;border-right:1px solid #858585;margin:0 5px;}
.main li .innerdiv .left{float:left;width:155px;height:300px;}
.main li .innerdiv .right{width:298px;height:296px;float:right;}
.main li .innerdiv .now {background-color:#fff;}
.main li .innerdiv span:hover{background-color:#fff;border-right:0;}
.main li:hover .innerdiv{display:block;}
.main li .innerdiv .right div{display:none;width:298px;height:300px;color:#000;}
?
/*显示内容*/
.main .innerdiv .right #player_block_1 .xiaoxue_right_top{width:292px;height:150px;color:#000;display:block;margin-top:5px;margin-left:4px;}
.main .innerdiv .right #player_block_1 .xiaoxue_right_top .xrt_left{width:180px;height:145px;border:1px solid #858585;float:left;display:block;}
.main .innerdiv .right #player_block_1 .xiaoxue_right_top .xrt_right{width:96px;float:right;height:145px;border:1px solid #858585;display:block;}
.main .innerdiv .right #player_block_1 .xiaoxue_right_middle{width:292px;height:90px;color:#000;display:block;margin:5px 0;margin-left:4px;}
.main .innerdiv .right #player_block_1 .xiaoxue_right_middle .xrm_left{width:180px;height:90px;border:1px solid #858585;float:left;display:block;}
.main .innerdiv .right #player_block_1 .xiaoxue_right_middle .xrm_right{width:96px;height:90px;border:1px solid #858585;float:right;display:block;}
.main .innerdiv .right #player_block_1 .xiaoxue_right_bottom{width:292px;height:30px;color:#000;display:block;margin-left:4px;}
.main .innerdiv .right #player_block_1 .xiaoxue_right_bottom a{display:block;float:left;margin:0 10px;font-size:12px;}
?
.main .innerdiv .right .bred{color:red;font-weight:boder;font-size:14px;}
.current{color:#000;padding:2px;cursor:pointer;width:150px;margin:0px 5px;border:1px solid #858585;border-top:0;border-right:0;display:block;background-color:#fff;}
</style>
<script type="text/javascript">
/**
?* 标签切换
?*id="player_nav_1" 鼠标点击的标签 _nav_是确定的 前面的可以更改?
?*id="player_block_1 要切换的内容 _block_是确定的前面的可以更改以用于不同的地方?
?*$(".awards_nav a").click(function(){switchBlock(this,4);}); 绑定事件?
?*/
function switchBlock(_this,count) ?
{ ?
?? ?var id=_this.id.replace(/^.+_/,""); ?
?? ?var name_space=_this.id.replace(/_.+/,""); ?
?? ?for(var i=1;i<=count;i++) ?
?? ?{ ?
?? ? ? ?jQuery("#"+name_space+"_nav_"+i).addClass("innerspan"); ?
?? ? ? ?document.getElementById(name_space+"_block_"+i).style.display="none"; ?
?? ?} ?
?? ?document.getElementById(_this.id).className="current"; ?
?? ?document.getElementById(name_space+"_block_"+id).style.display="block"; ?
}?
?
function switchSpan(_this,count)
{
?? ?var id=_this.id.replace(/^.+_/,""); ?
?? ?var name_space=_this.id.replace(/_.+/,"");?
?? ?for(var i=1;i<=count;i++) ?
?? ?{ ?
?? ? ? ?jQuery("#"+name_space+"_nav_"+i).removeClass("current"); ?
?? ?}?
?? ?document.getElementById(name_space+"_nav_"+id).className="current"; ?
}
</script>
<ul onmouseover="switchBlock(this,4)" ?id="player_nav_2" onmouseover="switchBlock(this,4)">小学二年级</span>
<span id="player_nav_3" onmouseover="switchBlock(this,4)">小学三年级</span> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
<span id="player_nav_4" onmouseover="switchBlock(this,4)">小学四年级</span>
<div class='borderline'>
</div>
</div>
<div onmouseover="switchSpan(this,4)" ?style="display:block">
<div class='xiaoxue_right_top'>
<div style="left:-156px">
<div onmouseover="switchBlock(this,3)" ?id="zhuzhong_nav_2" onmouseover="switchBlock(this,3)">初中二年级</span>
<span id="zhuzhong_nav_3" onmouseover="switchBlock(this,3)">初中三年级</span>
<div class='borderline' style="height:220px"></div>
</div>
<div ?style="display:block">
初中无敌
</div>
<div id="zhuzhong_block_2">
我们一起跳舞吧
</div>
<div id="zhuzhong_block_3">
就这样的来吧
</div>
</div>
</div>
</li>
<li>
<a href="javascript:void(0)">高中</a>
<div ?style="left:-312px">
<div onmouseover="switchBlock(this,3)" ? ?id="gaozhong_nav_2" onmouseover="switchBlock(this,3)">高中二年级</span>
<span id="gaozhong_nav_3" onmouseover="switchBlock(this,3)">高中三年级</span>
<div class='borderline' ?style="height:220px"></div>
</div>
<div ?style="display:block">
高中生活真美好啊
</div>
<div id="gaozhong_block_2">
有点压力了哦
</div>
<div id="gaozhong_block_3">
为理想的大学努力吧
</div>
</div>
</div>
</li>
</ul>
?
?