点击便变换内容的菜单
css文件如下:
<style type="text/css">
.centermenu .tabm { margin: 11px 5px 0px 5px; padding-left: 10px; border-bottom: 1px solid #FF7E00; z-index: 1;}
.centermenu .tabm li { margin: 0px; display: inline; list-style-type: none; }
.centermenu .tabm a, a.active { margin: 0px; padding: 5px 5px 0px 5px; border: 1px solid #FF7E00; color: #000; background: #fff; text-decoration: none;}
.centermenu .tabm a.active { background: #fff4d4; border-bottom: 3px solid #fff4d4; }
.centermenu .tabm a:hover { background: #fff4d4;}
.centermenu .activecontent { margin: 0px 5px; padding: 3px; border: 1px solid #ff7e00; border-top: none; height: 150px; color: #000; background: #fff4d4;}
.centermenu .hiddencontent { display: none; }
</style>
主体文件的head标签里插入:
<script language="javascript">
var ctcount=4;
function changct(cti)
{
for (i=1;i<=ctcount;i++)
{
ct=document.getElementById("ctab"+i);
cc=document.getElementById("ccontent"+i);
if(i==cti)
{
ct.className="active";
cc.className="activecontent";
}
else
{
ct.className="";
cc.className="hiddencontent";
}
}
}
</script>
主体文件body里加入:
<div class="centermenu">
<ul class="tabm">
<li><a id="ctab1" onclick="changct(1)" class="active" href="#">新闻</a></li>
<li><a id="ctab2" onclick="changct(2)" href="#">博客</a></li>
<li><a id="ctab3" onclick="changct(3)" href="#">论坛</a></li>
<li><a id="ctab4" onclick="changct(4)" href="#">图书</a></li>
</ul>
<div id="ccontent1" class="activecontent">
新闻里的内容
</div>
<div id="ccontent2" class="hiddencontent">
博客里的内容
</div>
<div id="ccontent3" class="hiddencontent">
论坛里的内容
</div>
<div id="ccontent4" class="hiddencontent">
图书里的内容
<a href="js.aspx">中间menu部分</a>
</div>
</div>
<style type="text/css">
.centermenu .tabm { margin: 11px 5px 0px 5px; padding-left: 10px; border-bottom: 1px solid #FF7E00; z-index: 1;}
.centermenu .tabm li { margin: 0px; display: inline; list-style-type: none; }
.centermenu .tabm a, a.active { margin: 0px; padding: 5px 5px 0px 5px; border: 1px solid #FF7E00; color: #000; background: #fff; text-decoration: none;}
.centermenu .tabm a.active { background: #fff4d4; border-bottom: 3px solid #fff4d4; }
.centermenu .tabm a:hover { background: #fff4d4;}
.centermenu .activecontent { margin: 0px 5px; padding: 3px; border: 1px solid #ff7e00; border-top: none; height: 150px; color: #000; background: #fff4d4;}
.centermenu .hiddencontent { display: none; }
</style>
主体文件的head标签里插入:
<script language="javascript">
var ctcount=4;
function changct(cti)
{
for (i=1;i<=ctcount;i++)
{
ct=document.getElementById("ctab"+i);
cc=document.getElementById("ccontent"+i);
if(i==cti)
{
ct.className="active";
cc.className="activecontent";
}
else
{
ct.className="";
cc.className="hiddencontent";
}
}
}
</script>
主体文件body里加入:
<div class="centermenu">
<ul class="tabm">
<li><a id="ctab1" onclick="changct(1)" class="active" href="#">新闻</a></li>
<li><a id="ctab2" onclick="changct(2)" href="#">博客</a></li>
<li><a id="ctab3" onclick="changct(3)" href="#">论坛</a></li>
<li><a id="ctab4" onclick="changct(4)" href="#">图书</a></li>
</ul>
<div id="ccontent1" class="activecontent">
新闻里的内容
</div>
<div id="ccontent2" class="hiddencontent">
博客里的内容
</div>
<div id="ccontent3" class="hiddencontent">
论坛里的内容
</div>
<div id="ccontent4" class="hiddencontent">
图书里的内容
<a href="js.aspx">中间menu部分</a>
</div>
</div>
浙公网安备 33010602011771号