javascript+css 实现tab功能

<!---------<html>
    <head>
        <style type="text/css">
.tabheader table {
  border-collapse: collapse; /* for IE */
  border-spacing: 0; /* for N6 */
}
.tabheader table tr td {margin:0;padding:0;border-width:0}
.tabheader .close {
  border-style: solid;
  border-width: 1px;
  border-color: #000;
  background-color: #d0d0d0;
  margin:0;
  padding: 0.5em;
  white-space: nowrap;
}
.tabheader .open {
  border-style: solid;
  border-width: 1px;
  border-color: #000 #000 #fff #000;
  background-color: white;
  margin:0;
  padding: 0.5em;
  white-space: nowrap;
}
.tabheader .spc {
  border-style: solid;
  border-width: 1px 0 1px 0;
  border-color: #fff #fff #000 #fff;
  margin:0;
  padding: 0.5em;
  white-space: nowrap;
}
.tabheader a {text-decoration: none;}
.tabbody {
  border-color: black;
  border-style: solid;
  border-width: 0 1px 1px 1px;
  padding: 1em;
}
</style>
<script language="JavaScript">
<!--

function seltab(bpref, hpref, id_max, selected) {
  if (! document.getElementById) return;
  for (i = 0; i <= id_max; i++) {
    if (! document.getElementById(bpref + i)) continue;
    if (i == selected) {
      document.getElementById(bpref + i).style.visibility = "visible";
      document.getElementById(bpref + i).style.position = "";
      document.getElementById(hpref + i).className = "open";
    } else {
      document.getElementById(bpref + i).style.visibility = "hidden";
      document.getElementById(bpref + i).style.position = "absolute";
      document.getElementById(hpref + i).className = "close";
    }
  }
}
// -->
</script>
<title>Tab功能</title>
</head>
    <body bgcolor="white" οnlοad="seltab('box', 'head', 10, 1)">
        <h1></h1>
        <div class="tabheader">
            <table>
                <tr>
                    <td>
                        <div id="head1">
                            <a href="javascript:seltab('box', 'head', 10, 1)">tab1</a>
                        </div>
                    </td>
                    <td><div class="spc"> </div>
                    </td>
                    <td>
                        <div id="head2">
                            <a href="javascript:seltab('box', 'head', 10, 2)">tab2</a>
                        </div>
                    </td>
                    <td><div class="spc"> </div>
                    </td>
                    <td>
                        <div id="head3">
                            <a href="javascript:seltab('box', 'head', 10, 3)">tab3</a>
                        </div>
                    </td>
                    <td><div class="spc"> </div>
                    </td>
                    <td>
                        <div id="head4">
                            <a href="javascript:seltab('box', 'head', 10, 4)">tab4</a>
                        </div>
                    </td>
                    <td width="100%"><div class="spc"> </div>
                    </td>
                </tr>
            </table>
        </div>
        <div class="tabbody">
            <div id="box1">
                <p>
                    test
                </p>
            </div>
            <div id="box2">
                <p>test
                </p>
                <p>test
                </p>
            </div>
            <div id="box3">
                <p>testtesttest
                </p>
            </div>
            <div id="box4">
                <p>
                    testtest
                </p>
            </div>
        </div>
        </div>
    </body>
</html> ----------------------->

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值