我要那种选项卡在下面的,就像excel的sheet一样在下面的那种,哪位好心人有资源的话 分享一下,谢谢

解决方案 »

  1.   

    样式自己调<!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=utf-8" />
        <title>选项卡</title>
        <style type="text/css">
        *{margin:0px;padiving:0px;}
        body{ padiving:0;font:12px "宋体"; height:100%; width:100%; }
        ul,li{ list-style-type:none;}
        .content{width:962px;height:auto;margin:100px auto;border:1px solid #888;}
        .tabHeads{width:960px;height:30px;margin:0px auto;background-color:#ddd;border:1px solid #ddd;border-bottom:none;}
        .tabContents{width:960px;height:200px;margin:0px auto; border:1px solid #ddd;border-top:none;background-color:blue; }
        .tabContents div{height:190px;line-height:25px;width:auto;padding:5px;overflow:auto;background-color:#eff;}
        .tabs{width:120px;height:25px;line-height:25px;float:left;margin-top:5px;text-align:center;display:inline;}
        .curTab{color:red;background-color:#eff; }
     </style>
    </head>
    <body>
    <div class='content'>
          
            <div id="tabContents" class="tabContents">
                <div >
                    <textarea rows=3 cols="20">1</textarea>新闻1
                </div>
                <div style="display:none;">
                    <textarea   rows=3 cols="20">22</textarea>新闻2
                </div>
                <div  style="display:none;">
                    <textarea  rows=3 cols="20">333</textarea>新闻3
                </div>
                <div style="display:none;">
                    <textarea   rows=3 cols="20">4444</textarea>新闻4
                </div>
                <div style="display:none;">
                    <textarea   rows=3 cols="20">55555</textarea>新闻5
                </div>
                <div style="display:none;" >
                    <textarea  rows=3 cols="20">666666</textarea>新闻6
                </div>
            </div>
            <div class="tabHeads" id='tabHeads'>
                <ul>
                    <li style="margin-left:40px;">新闻1</li>
                    <li >新闻2</li>
                    <li >新闻3</li>
                    <li >新闻4</li>
                    <li >新闻5</li>
                    <li >新闻6</li>
                </ul>
            </div>
        </div>   
        <div class='content'>
            <div class="tabHeads" id='tabHeads1'>
                <ul>
                    <li style="margin-left:40px;">新闻1</li>
                    <li >新闻2</li>
                    <li >新闻3</li>
                    <li >新闻4</li>
                    <li >新闻5</li>
                    <li >新闻6</li>
                </ul>
            </div>
            <div id="tabContents1" class="tabContents">
                <div >
                    <textarea   rows=3 cols="20">1</textarea>新闻1
                </div>
                <div style="display:none;">
                    <textarea   rows=3 cols="20">22</textarea>新闻2
                </div>
                <div  style="display:none;">
                    <textarea  rows=3 cols="20">333</textarea>新闻3
                </div>
                <div style="display:none;">
                    <textarea   rows=3 cols="20">4444</textarea>新闻4
                </div>
                <div style="display:none;">
                    <textarea   rows=3 cols="20">55555</textarea>新闻5
                </div>
                <div style="display:none;" >
                    <textarea  rows=3 cols="20">666666</textarea>新闻6
                </div>
            </div>
        </div>
    </body>
    <script type="text/javascript"></script>
    <script type="text/javascript">if(typeof(HTMLElement)!='undefined')  // 给非IE 浏览器添加方法 contains
    {
        HTMLElement.prototype.contains = function(obj)
        {  
          while(obj && obj.tagName)  
          {
                if(obj == this)
                  return true;
                obj = obj.parentNode;
          }   
                return false;  
        };  
    }var $ = function (id,obj) { 
        return 'string' == typeof(id) ? (obj||document).getElementById(id) : id;  
    }; 
    var $$ = function (name,obj) { 
        return 'string' == typeof(name) ? (obj||document).getElementsByTagName(name):name;  
    }; //选项卡类,头,内容,选中的索引,选中样式,默认样式,是否自动切换,切换时间间隔(毫秒)
    function Tab(heads,contents,selectedIndex,curStyle,style,isAutoChange,space)
    {
        if(heads && contents && heads.length && contents.length &&  heads.length==contents.length)
        {
            this.heads=heads;
            this.contents=contents;
        }else
        {
            alert("参数错误!"); return;
        }
        this.selectedIndex = selectedIndex||0;
        this.curStyle=curStyle||"";
        this.style = style||"";
        this.isAutoChange=isAutoChange||false;
        this.space = space || 3000;
        this.timer=null;
        this.init();
    }Tab.prototype.init=function()
    {
        var obj = this;
        for(var i=0;i<obj.heads.length;i++)
        {
            obj.heads[i].index=i;
            obj.heads[i].onmouseover=function(){obj.setTab(this.index);if(obj.isAutoChange){clearInterval(obj.timer);}};
            if(obj.isAutoChange)
            {
                 obj.contents[i].onmouseout=obj.heads[i].onmouseout=function(e){
                    e = e||event;
                    e = e.toElement || e.relatedTarget ; // IE toElement  FF:relatedTarget
                   if(typeof(e)!="undefined" &&!this.contains(e)){clearInterval(obj.timer);obj.timer=setInterval(function(){obj.setTab(obj.selectedIndex=(++obj.selectedIndex)%obj.heads.length);},obj.space);}
                };
                obj.contents[i].onmouseover=function(e){clearInterval(obj.timer);};
            }
        }
        if(obj.isAutoChange){obj.timer=setInterval(function(){obj.setTab(obj.selectedIndex=(++obj.selectedIndex)%obj.heads.length);},obj.space);}
        obj.setTab( obj.selectedIndex);
    }
    Tab.prototype.setTab=function(index)
    {
         for(var i=0;i<this.heads.length;i++)
        {
            this.heads[i].className = i == index ? this.style+' '+this.curStyle :this.style;
            this.contents[i].style.display = i == index ? "block" : "none";
        }
        this.selectedIndex = index;
    }
    window.onload=function()
    {
        var heads = $("tabHeads");
        var contents=$("tabContents");
        var tab1=new Tab($$('li',heads),getChilds(contents),0,'curTab','tabs');    var heads1 = $("tabHeads1");
        var contents1=$("tabContents1");
        var tab2=new Tab($$('li',heads1),getChilds(contents1),0,'curTab','tabs',true,1500);
       
    };function getChilds(o)
    {
        if(!o || !o.childNodes)return null;
        var r=[];
        for(var i=0;i<o.childNodes.length;i++){
          if(o.childNodes[i].tagName){r.push(o.childNodes[i]);}
        }
        return r;
    }</script></html>
      

  2.   

    http://www.open-open.com/news/view/154e842