A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 石国庆 中级黑马   /  2013-4-10 20:53  /  1212 人查看  /  6 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

大家可以说说做选项卡效果都有哪些方法,或者是我下面的代码怎么可以优化一下?
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
        #tablianxi{
        position:absolute;
        left:35%;
        top:10%;
        }
        .tab{
          float:left;
          width:303px;
          border:1px solid;
          border-right-style:none;
          border-bottom-style:none;
          }
        .xuanzhong{
      float:left;
          width:100px;
          text-align:center;
          border-right-width:1px;
          border-right-style:solid;
          border-right-color:#000000;
          background-color:#CC6633;
          border-bottom-style:none;
        }
        .buzhong{
          float:left;
          width:100px;
          text-align:center;
          border-right-width:1px;
          border-right-style:solid;
          border-right-color:#000000;
          border-bottom-width:1px;
          border-bottom-style:solid;
          border-bottom-color:#000000;
        }
        .tabcontent{
          clear:both;
          width:302px;
          min-height:300px;
          border:1px solid #000000;
          border-top-style:none;
          background-color:#CC6633;
        }
       
</style>
<script type="text/javascript" language="javascript">
    function change(num) {
        var t = document.getElementById("tabtop").getElementsByTagName("div");
        for (var i = 0; i < t.length; i++) {
            t[i].className = "buzhong";}
        t[num].className = "xuanzhong";   
               
                var y = document.getElementById("tabbottom").getElementsByTagName("div");
        for (var j = 0; j < y.length; j++) {
            y[j].style.display = "none"}
        y[num].style.display = "block";
     }

</script>
</head>

<body>
<div id="tablianxi">
<div id="tabtop" class="tab">
<div class="xuanzhong" onmouseover="change(0)">选项卡1</div>
<div class="buzhong" onmouseover="change(1)">选项卡2</div>
<div class="buzhong" onmouseover="change(2)">选项卡3</div>
</div>
<div id="tabbottom">
<div class="tabcontent" style="display:block;">div1</div>
<div class="tabcontent" style="display:none;">div2</div>
<div class="tabcontent" style="display:none;">div3</div>
</div>
</div>
</body>

评分

参与人数 1技术分 +1 收起 理由
苏波 + 1

查看全部评分

6 个回复

正序浏览
郑丹丹1990 发表于 2013-4-10 21:45
可能是你图片的问题,我把你代码拷贝到vs2008中试了下,图片就不显示。
就好像保存文档时,字符编码格式 ...

你把图片的地方都换成:#就行了
回复 使用道具 举报
石国庆 发表于 2013-4-10 20:55
害羞的地方都是:#

可能是你图片的问题,我把你代码拷贝到vs2008中试了下,图片就不显示。
就好像保存文档时,字符编码格式一样的问题。
vs 可能不认识那个图片吧!
回复 使用道具 举报
郑丹丹1990 发表于 2013-4-10 21:35
这个东西真好,我想要你最终的解决方案,可否???

啊?我没有什么解决方案,就是今天练习css在html里面写的,上面的代码加上<html>标签就能显示了
回复 使用道具 举报
石国庆 发表于 2013-4-10 20:55
害羞的地方都是:#

这个东西真好,我想要你最终的解决方案,可否???
回复 使用道具 举报
这个我不知道,但是我有一个asp.net+tab  效果如下:

as.JPG (5.84 KB, 下载次数: 10)

as.JPG

评分

参与人数 1技术分 +1 收起 理由
苏波 + 1

查看全部评分

回复 使用道具 举报
害羞的地方都是:#
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马