CSS实例(四):实现TabView(页签)效果

今天花了点时间,设计了一个网页上用的tabview(页签、tabcontrol)效果,网页元素用得比较少,js代码也比较精练。测试了一下支持IE、FireFox以及chrome。支持同一页面上多处使用。
  没有什么过多说的。先看一下效果。



页面中用到一个图片:




页面代码如下:
Html代码 收藏代码
  1. <!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <htmlxmlns="http://www.w3.org/1999/xhtml">
  3. <head><title>tabview示例(欢迎访问我的博客:http://wallimn.iteye.com)</title>
  4. <metahttp-equiv=content-typecontent="text/html;charset=GBK">
  5. <scripttype="text/javascript">
  6. functiontabclick(obj){
  7. if(obj.className=='cur')return;
  8. varidx;
  9. for(varn=0;n<obj.parentNode.childNodes.length;n++){
  10. obj.parentNode.childNodes[n].className="";
  11. if(obj==obj.parentNode.childNodes[n])idx=n;
  12. }
  13. obj.className="cur";
  14. varpc=obj.parentNode.nextSibling;
  15. while(pc.nodeType==3)pcpc=pc.nextSibling;
  16. for(varn=0;n<pc.childNodes.length;n++){
  17. pc.childNodes[n].className="hdn";
  18. }
  19. pc.childNodes[idx].className="";
  20. }
  21. </script>
  22. <styletype="text/css">
  23. .debug{
  24. border:1pxsolidred;
  25. }
  26. .hdn{
  27. display:none;
  28. }
  29. ul.tabbar,ul.tabpage{
  30. list-style-type:none;
  31. margin:0;
  32. font-size:12px;
  33. padding:0;
  34. }
  35. ul.tabbar{
  36. background:url(tabview.gif)repeat-x0-68px;
  37. height:34px;
  38. }
  39. ul.tabbarli{
  40. float:left;
  41. width:83px;
  42. height:34px;
  43. line-height:34px;
  44. text-align:center;
  45. background:url(tabview.gif);
  46. cursor:pointer;
  47. cursor:hand;
  48. }
  49. ul.tabbarli.cur{
  50. background:url(tabview.gif)0-34px;
  51. }
  52. ul.tabpage{
  53. border-style:ridge;
  54. border-color:#dceefd;
  55. border-width:02px2px2px;
  56. height:302px;
  57. overflow:hidden;
  58. }
  59. ul.tabpageli{
  60. height:300px;
  61. border-width:0;
  62. overflow-y:auto;
  63. }
  64. </style>
  65. </head>
  66. <body>
  67. <ulclass="tabbar">
  68. <listyle="margin-left:1em"class="cur"onclick="tabclick(this)">过滤条件</li>
  69. <lionclick="tabclick(this)">排序条件</li>
  70. <lionclick="tabclick(this)">分  组</li>
  71. <lionclick="tabclick(this)">计算字段</li>
  72. </ul>
  73. <ulclass="tabpage">
  74. <li>显示过滤条件</li>
  75. <liclass="hdn">显示排序条件</li>
  76. <liclass="hdn">显示分  组</li>
  77. <liclass="hdn">显示计算字段</li>
  78. </ul>
  79. </body>
  80. </html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值