选项卡实现

<!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>test</title>
<style type="text/css">
<!--
* {
margin: 0; padding:0
}
body {
margin-top: 10px;
margin-right: auto;
margin-bottom: 10px;
margin-left: auto;
text-align: center;
height: auto;
width: auto;
background-color: #666666;
font-size: 12px;
color: #000000;
}
#container {
text-align: left;
width: 800px;
height: 400px;
background-color: #FFFFFF;
padding: 20px;
}

#container #title {
height: 28px;
}
#container #title li {
float: left;
list-style-type: none;
height: 28px;
line-height: 28px;
text-align: center;
margin-right: 1px;
}
#container #title ul {
background-color: #FFFFFF;
height: 28px;
}
#container #title a {
text-decoration: none;
color: #000000;
display: block;
width: auto;
background: url(http://img293.imageshack.us/img293/1049/tabselectedleftbk2up3.jpg) no-repeat left -29px;
}
#container #title a span{
display: block;
background: url(http://img293.imageshack.us/img293/4991/tabselectedrightbk2vd2.jpg) no-repeat right -29px;
padding: 0 15px 0 15px;
}
#container #title #tag1 a:hover {
text-decoration: none;
color: #ffffff;
display: block;
width: auto;
background: url(http://img293.imageshack.us/img293/1049/tabselectedleftbk2up3.jpg) no-repeat left -87px;
}
#container #title #tag1 a:hover span{
display: block;
background: url(http://img293.imageshack.us/img293/4991/tabselectedrightbk2vd2.jpg) no-repeat right -87px;
padding: 0 15px 0 15px;
}
#container #title #tag2 a:hover {
text-decoration: none;
color: #ffffff;
display: block;
width: auto;
background: url(http://img293.imageshack.us/img293/1049/tabselectedleftbk2up3.jpg) no-repeat left 0px;
}
#container #title #tag2 a:hover span{
display: block;
background: url(http://img293.imageshack.us/img293/4991/tabselectedrightbk2vd2.jpg) no-repeat right 0px;
padding: 0 15px 0 15px;
}
#container #title #tag3 a:hover {
text-decoration: none;
color: #ffffff;
display: block;
width: auto;
background: url(http://img293.imageshack.us/img293/1049/tabselectedleftbk2up3.jpg) no-repeat left -58px;
}
#container #title #tag3 a:hover span{
display: block;
background: url(http://img293.imageshack.us/img293/4991/tabselectedrightbk2vd2.jpg) no-repeat right -58px;
padding: 0 15px 0 15px;
}
#container #title #tag4 a:hover {
text-decoration: none;
color: #ffffff;
display: block;
width: auto;
background: url(http://img293.imageshack.us/img293/1049/tabselectedleftbk2up3.jpg) no-repeat left -145px;
}
#container #title #tag4 a:hover span{
display: block;
background: url(http://img293.imageshack.us/img293/4991/tabselectedrightbk2vd2.jpg) no-repeat right -145px;
padding: 0 15px 0 15px;
}
#container #title #tag5 a:hover {
text-decoration: none;
color: #ffffff;
display: block;
width: auto;
background: url(http://img293.imageshack.us/img293/1049/tabselectedleftbk2up3.jpg) no-repeat left -174px;
}
#container #title #tag5 a:hover span{
display: block;
background: url(http://img293.imageshack.us/img293/4991/tabselectedrightbk2vd2.jpg) no-repeat right -174px;
padding: 0 15px 0 15px;
}
#container #title .selectli1 {
text-decoration: none;
color: #ffffff;
display: block;
width: auto;
background: url(http://img293.imageshack.us/img293/1049/tabselectedleftbk2up3.jpg) no-repeat left -87px;
}
#container #title a .selectspan1 {
display: block;
background: url(http://img293.imageshack.us/img293/4991/tabselectedrightbk2vd2.jpg) no-repeat right -87px;
padding: 0 15px 0 15px;
}
#container #title .selectli2 {
text-decoration: none;
color: #ffffff;
display: block;
width: auto;
background: url(http://img293.imageshack.us/img293/1049/tabselectedleftbk2up3.jpg) no-repeat left 0px;
}
#container #title a .selectspan2 {
display: block;

background: url(http://img293.imageshack.us/img293/4991/tabselectedrightbk2vd2.jpg) no-repeat right 0px;
padding: 0 15px 0 15px;
}
#container #title .selectli3 {
text-decoration: none;
color: #ffffff;
display: block;
width: auto;
background: url(http://img293.imageshack.us/img293/1049/tabselectedleftbk2up3.jpg) no-repeat left -58px;
}
#container #title a .selectspan3 {
display: block;
background: url(http://img293.imageshack.us/img293/4991/tabselectedrightbk2vd2.jpg) no-repeat right -58px;
padding: 0 15px 0 15px;
}
#container #title .selectli4 {
text-decoration: none;
color: #ffffff;
display: block;
width: auto;
background: url(http://img293.imageshack.us/img293/1049/tabselectedleftbk2up3.jpg) no-repeat left -145px;
}
#container #title a .selectspan4 {
display: block;
background: url(http://img293.imageshack.us/img293/4991/tabselectedrightbk2vd2.jpg) no-repeat right -145px;
padding: 0 15px 0 15px;
}
#container #title .selectli5 {
text-decoration: none;
color: #ffffff;
display: block;
width: auto;
background: url(http://img293.imageshack.us/img293/1049/tabselectedleftbk2up3.jpg) no-repeat left -174px;
}
#container #title a .selectspan5 {
display: block;
background: url(http://img293.imageshack.us/img293/4991/tabselectedrightbk2vd2.jpg) no-repeat right -174px;
padding: 0 15px 0 15px;
}
#container #content ul {margin: 10px;}
#container #content li {margin: 5px; }
#container #content li img {margin: 5px;display:block;}
#container #content {
height: 150px;
padding: 10px;
}
.content1 {
border-top-width: 2px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
border-top-style: solid;
border-right-style: solid;
border-bottom-style: solid;
border-left-style: solid;
border-top-color: #66A9E6;
border-right-color: #66A9E6;
border-bottom-color: #66A9E6;
border-left-color: #66A9E6;
background-color: #fafafa;
}
.content2 {
border-top-width: 2px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
border-top-style: solid;
border-right-style: solid;
border-bottom-style: solid;
border-left-style: solid;
border-top-color: #66A9E6;
border-right-color: #66A9E6;
border-bottom-color: #66A9E6;
border-left-color: #66A9E6;
background-color: #fafafa;
}
.content3 {
border-top-width: 2px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
border-top-style: solid;
border-right-style: solid;
border-bottom-style: solid;
border-left-style: solid;
border-top-color: #66A9E6;
border-right-color: #66A9E6;
border-bottom-color: #66A9E6;
border-left-color: #66A9E6;
background-color: #fafafa;
}
.content4 {
border-top-width: 2px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
border-top-style: solid;
border-right-style: solid;
border-bottom-style: solid;
border-left-style: solid;
border-top-color: #66A9E6;
border-right-color: #66A9E6;
border-bottom-color: #66A9E6;
border-left-color: #66A9E6;
background-color: #fafafa;
}
.content5 {
border-top-width: 2px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
border-top-style: solid;
border-right-style: solid;
border-bottom-style: solid;
border-left-style: solid;
border-top-color: #66A9E6;
border-right-color: #66A9E6;
border-bottom-color: #66A9E6;
border-left-color: #66A9E6;
background-color: #fafafa;
}
.hidecontent {display:none;}
-->
</style>
<script language="javascript">
function switchTag(tag,content)
{
// alert(tag);
// alert(content);
for(i=1; i <6; i++)
{
if ("tag"+i==tag)
{
document.getElementById(tag).getElementsByTagName("a")[0].className="selectli"+i;
document.getElementById(tag).getElementsByTagName("a")[0].getElementsByTagName("span")[0].className="selectspan"+i;
}else{
document.getElementById("tag"+i).getElementsByTagName("a")[0].className="";
document.getElementById("tag"+i).getElementsByTagName("a")[0].getElementsByTagName("span")[0].className="";
}
if ("content"+i==content)
{
document.getElementById(content).className="";
}else{
document.getElementById("content"+i).className="hidecontent";
}
document.getElementById("content").className=content;
}
}
</script>
</head>

<body>
<div id="container">
<div id="title">
<ul>
<li id="tag1"><a href="#" οnclick="switchTag('tag1','content1');this.blur();" class="selectli1"><span class="selectspan1"> 选项一</span></a></li>
<li id="tag2"><a href="#" οnclick="switchTag('tag2','content2');this.blur();"><span>选项二</span></a></li>
<li id="tag3"><a href="#" οnclick="switchTag('tag3','content3');this.blur();"><span>选项三</span></a></li>
<li id="tag4"><a href="#" οnclick="switchTag('tag4','content4');this.blur();"><span>选项四</span></a></li>
<li id="tag5"><a href="#" οnclick="switchTag('tag5','content5');this.blur();"><span>选项五</span></a></li>
</ul>
</div>
<div id="content" class="content1">
<div id="content1"><p>NBA</p>乔丹</div>
<div id="content2" class="hidecontent">韦德</div>
<div id="content3" class="hidecontent">詹姆斯</div>
<div id="content4" class="hidecontent">科比</div>
<div id="content5" class="hidecontent">保罗</div>
</div>

</div>
</body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值