网页Tab 标签

  今年开始才参加Web开发,然后对Web程序产生了浓厚的兴趣,先后研究学习了.net页面运行的流程,自定义控件,js,div布局以及JQuery。感觉收获还是蛮大的。闲来无事,所以想写一些东西。

  每天都会去163浏览新闻以及其中的评论,163主新闻区使用了 网页Tab来显示各个分类的新闻。这里我也写了一个,运行效果图如下:

   

  代码:

 

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TestTab.aspx.cs" Inherits="TestTab" %>
<!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 runat="server">
    <title>无标题页</title>
    <style type="text/css">
        body
        {
            font-size:12px;
        }
        
        .normal
        {
              list-style: none; float: left;
              padding: 5px 2px 2px 2px;
              width: 90px; text-align :center ;
              vertical-align :middle ;
              cursor :pointer ;
              
              border-bottom :solid 1px #9cd9f5;
              border-right :solid 1px #9cd9f5;
            
              background-color: #dee7f5;
              border-collapse :separate ;
        }
        .selected
        {
             list-style: none;
             float: left;
             padding: 5px 2px 2px 2px;
             width: 90px;
             text-align :center ;
             vertical-align :middle ;
             cursor :pointer ;
              
             border-bottom :solid 0px #9cd9f5;
             border-right :solid 1px #9cd9f5;
             background-color:#f8f8f8 ;
        }
        
        #divMainTab
        {
             border-left :solid 1px #9cd9f5;
             border-top :solid 1px #9cd9f5;
             float:left;
             margin: 0px; padding: 0px
        }
        
        .divContent
        {
                width: 474px;
                height: 400px;
                clear: both;
                border-bottom: solid 1px #9cd9f5;
                border-left: solid 1px #9cd9f5;
                border-right: solid 1px #9cd9f5;
        }
       
        a{
            text-decoration: none;
            color: #00ccff;
        }
        a:hover
        {
            text-decoration: underline;
            color: #cc0000;
        }
    </style>

    <script language="javascript" type="text/javascript">
        function changeTab(index)
        {
            for (var i=1;i<=5;i++)
            {
                document.getElementById ("li_"+i).className ="normal";
                document.getElementById ("li_"+index).className ="selected";
                
                document.getElementById ("div"+i).style.display  ="none";
            }
            
            document.getElementById ("div1").innerText= "XXXXXXX"+index;
            document.getElementById ("div"+index).style.display  ="block";
       }
    </script>

</head>
<body>
    <form id="form1" runat="server">
        <div>
            <div id="divMainTab">
                <ul style="list-style: none; margin: 0px; padding: 0px; border-collapse: collapse;">
                   
                    <li id="li_1" class="selected" οnmοuseοver="changeTab('1')"><a href="#">我我我你你1</a> </li>
                    <li id="li_2" class="normal" οnmοuseοver="changeTab('2')"><a href="#">我我我你你2</a> </li>
                    <li id="li_3" class="normal" οnmοuseοver="changeTab('3')"><a href="#">我我我你你3</a> </li>
                    <li id="li_4" class="normal" οnmοuseοver="changeTab('4')"><a href="#">我我我你你4</a> </li>
                    <li id="li_5" class="normal" οnmοuseοver="changeTab('5')"><a href="#">我我我你你5</a> </li>
                </ul>
            
            </div>
            <div   id="div1" style ="display :block" class ="divContent">
                111111111111111
            </div>
             <div  id="div2" style ="display :none" class ="divContent">
                222222222222222
            </div>
             <div  id="div3" style ="display :none" class ="divContent">
                3333333333333333
            </div>
             <div id="div4" style ="display :none" class ="divContent">
                4444444444444444
            </div>
             <div   id="div5" style ="display :none" class ="divContent">
                5555555555555555555
            </div>
        </div>
    </form>
</body>
</html>

 

  具体代码解析就不解析了,很简单。

转载于:https://www.cnblogs.com/aierduo/archive/2009/11/17/1604384.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值