分享

css+div实现标签卡Tab效果

 WindySky 2009-03-19

用css+div实现的一个简单的标签卡的功能,最终效果如下面两张图片:



代码如下:

  1. <STYLE type="text/css">    
  2.  * {   
  3.      list-style-type:none;   
  4.      font-size:12px;   
  5.      text-decoration:none;   
  6.      margin:0;   
  7.      padding:0;   
  8.  }   
  9.    .ucatch {   
  10.      width:800px;   
  11.      height:600px;   
  12.      overflow:hidden;   
  13.      margin:100px 100px;   
  14.  }   
  15.  .p1 {   
  16.      display:block;   
  17.      width:186px;   
  18.      heigth:30px;   
  19.      line-height:34px;   
  20.      font-size:12px;   
  21.      color:3b536a;   
  22.      font-weight:bold;   
  23.      background:url(c.png) no-repeat;   
  24.  }   
  25.  .p2 {   
  26.      display:block;   
  27.      width:161px;   
  28.      heigth:30px;   
  29.      line-height:34px;   
  30.      font-size:12px;   
  31.      color:898989;   
  32.      font-weight:bold;   
  33.      background:url(d.png) no-repeat;   
  34.  }   
  35.  .p3 {   
  36.      display:block;   
  37.      width:161px;   
  38.      heigth:30px;   
  39.      line-height:34px;   
  40.      font-size:12px;   
  41.      color:898989;   
  42.      font-weight:bold;   
  43.      background:url(e.png) no-repeat;   
  44.  }   
  45.  .ucatch_title {   
  46.  margin-left:30px;   
  47.  }   
  48.  .ucatch_title li {   
  49.      display:block;   
  50.      float:left;   
  51.      margin:11px 0 0 0;   
  52.      display:inline;   
  53.      text-align:center;   
  54.  }   
  55.  .ucatch_body {   
  56.      clear:both;   
  57.      display:block;   
  58.      width:800px;   
  59.      height:500px;   
  60.      background:url(a.png) no-repeat; overflow:hidden;   
  61.  }   
  62.  .bb {   
  63.  width:800px;   
  64.  height:85px;   
  65.  background:url(b.png) no-repeat; overflow:hidden;   
  66.  }   
  67.  .ucatch_text{   
  68.  margin:10px 0 0 20px;   
  69.  font:LMAnomRegExt;   
  70.  font-size:28px;   
  71.  color:white;   
  72.  font-weight:bold;   
  73.  }   
  74.  .test{   
  75.  margin:10px 0 0 10px;   
  76.  background:white;   
  77.  width:780px;   
  78.  height:365px;   
  79.  }   
  80.  </STYLE>   
  81.  <script language="javascript">    
  82.    function ucatch(num){   
  83.      for(var id = 1;id<=2;id++)   
  84.      {   
  85.      var testbody="test"+id;   
  86.      var p = "p"+id;   
  87.      if(id==num){   
  88.      document.getElementById(testbody).style.display="block";   
  89.      document.getElementById(p).className="p1";   
  90.      }   
  91.      else{   
  92.          document.getElementById(testbody).style.display="none";   
  93.          if(id==1){   
  94.              document.getElementById(p).className="p3";   
  95.          }else{   
  96.              document.getElementById(p).className="p2";   
  97.          }   
  98.      }   
  99.      }   
  100.      }   
  101.  </script>    
  102.   
  103.     <div class="ucatch">   
  104.      <div class="bb">   
  105.      <div class="ucatch_text">UCATCH</div>   
  106.      <ul class="ucatch_title" id="woaicsstitle">   
  107.          <li><a class="p1" id="p1" xhref="javascript:void(0)" onclick="javascript:ucatch(1)">Tab One</a></li>   
  108.          <li><a class="p2" id="p2" xhref="javascript:void(0)" onclick="javascript:ucatch(2)">Tab Two</a></li>   
  109.      </ul>   
  110.      </div>   
  111.      <div class="ucatch_body">   
  112.          <div class="test" id="test1" style="display:block;">欢迎来到UCATCH</div>   
  113.          <div class="test" id="test2" style="display:none;">www.ucatch.cn</div>   
  114.      </div>    
  115.    </div>  

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约