javascript标签页翻动效果(实例分享)(图文)

发布时间:2019-08-24编辑:脚本学堂
本文介绍下,用javascript代码实现的一个标签页翻动效果的例子,有需要的朋友参考下。

js标签页翻动效果。代码如下:

<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
        <meta http-equiv="Content-Type" content="text/html;charset=gb2312" /> 
        <title>简洁Tab--www.jb200.com</title> 
        <style type="text/css">      
        body,div,ul,li{padding:0;text-align:center; } 
        body{font:9pt "宋体"; } 
        
        ul{ list-style:none;} 
        /*选项卡1*/ 
        #Tab1{ width:460px; margin:0px;padding:0px;margin:0 auto;} 
        /*选项卡2*/ 
        #Tab2{ width:576px; margin:0px; padding:0px; margin:0 auto;} 
        /*菜单class*/ 
        .Menubox {width:100%;background:url(/d/file/jb/js/20130721132337.gif);  height:28px; line-height:28px; } 
        .Menubox ul{ margin:0px; padding:0px; } 
        .Menubox li{ float:left; display:block; cursor:pointer; width:114px; text-align:center; color:#949694; font-weight:bold; } 
        .Menubox li.hover{ padding:0px; background:#fff; width:116px;  border-left:1px solid #A8C29F; border-top:1px solid #A8C29F; 
                border-right:1px solid #A8C29F; background:url(/d/file/jb/js/20130721132405.gif);  
                color:#739242; font-weight:bold; height:27px; line-height:27px;  } 
        .Contentbox{clear:both; margin-top:0px; border:1px solid #A8C29F; border-top:none; height:181px; text-align:center; 
                padding-top:8px;}      
        </style> 
        <script type="text/javascript" language="javascript"> 
            //函数
            function setTab(name, cursel, n) 
            {
                for (i = 1; i <= n; i++) 
                { 
                    var menu=document.getElementById(name+i); 
                    var con=document.getElementById("con_"+name+"_"+i); 
                    menu.className=i==cursel?"hover":""; 
                    con.style.display=i==cursel?"block":"none"; 
                } 
            } 
        </script> 
</head>
<body>
    <div id="Tab1"> 
        <div class="Menubox"> 
            <ul> 
                <li id="one1" onclick="setTab('one',1,4)" class="hover">新闻1</li> 
                <li id="one2" onclick="setTab('one',2,4)" >新闻2</li> 
                <li id="one3" onclick="setTab('one',3,4)">新闻3</li> 
                <li id="one4" onclick="setTab('one',4,4)">新闻4</li> 
            </ul> 
        </div> 
        <div class="Contentbox"> 
            <div id="con_one_1" class="hover">脚本学堂 http://www.jb200.com</div> 
            <div id="con_one_2" style="display:none">新闻列表2</div> 
            <div id="con_one_3" style="display:none">新闻列表3</div> 
            <div id="con_one_4" style="display:none">新闻列表4</div> 
        </div> 
    </div> 
    
    </br>
    <hr />
    </br>     
    <div id="Tab2"> 
        <div class="Menubox"> 
            <ul> 
                <li id="two1" onmouseover="setTab('two',1,4)" onclick="setTab('two',1,4)" class="hover">新闻1</li> 
                <li id="two2" onmouseover="setTab('two',2,4)" onclick="setTab('two',2,4)" >新闻2</li> 
                <li id="two3" onmouseover="setTab('two',3,4)" onclick="setTab('two',3,4)">新闻3</li> 
                <li id="two4" onmouseover="setTab('two',4,4)" onclick="setTab('two',4,4)">新闻4</li> 
            </ul> 
        </div> 
        <div class="Contentbox"> 
            <div id="con_two_1" >新闻列表1</div> 
            <div id="con_two_2" style="display:none">脚本学堂 http://www.jb200.com</div> 
            <div id="con_two_3" style="display:none">新闻列表3</div> 
            <div id="con_two_4" style="display:none">新闻列表4</div> 
        </div> 
    </div>
</body>
</html>

标签页翻动效果图1:
标签页翻动效果(1)

标签页翻动效果图2:
标签页翻动效果(2)