总的来说思路比较简单,就是先获取节点,然后对节点进行相应的处理,下面是完整的页面代码:
原生js:
原生js tab .tab{ margin:10px auto; position:relative; width:300px; } ul,li{ list-style-type:none; padding:0; margin:0; font:13px/20px SimSun,arial; color:#333; text-align:center; } .tabTltle ul li{ float:left; position:relative; background:#fefefe; background:-webkit-gradient(linear,left top,left bottom, from(#fefefe), to(#ededed)); padding:7px 15px; border:1px #ddd solid; margin-right:-1px; cursor:pointer; } .tabTltle ul li.active{ background:#fff; font-weight: bold; } .clearfix{ } .clearfix:after{ display:block; clear:both; overflow:hidden; content:""; } .tabConn{ border:1px #eee solid; position:relative; height:100px } .tabConn div{ position:absolute; opacity:0; filter:alpha(opacity=0); padding:5px; text-align:center; width:100%; } .tabConn div.current{ opacity:1; filter:alpha(opacity=100); } aaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb cccccccccccccccccccccccccccccccc ddddddddddddddddddddddddddddd
- 标题一
- 标题二
- 标题三
- 标题四
下面我们来看一下jQuery写的(css共用,需要引进jQuery库):
jQuery tab .tab{ margin:10px auto; position:relative; width:300px; } ul,li{ list-style-type:none; padding:0; margin:0; font:13px/20px SimSun,arial; color:#333; text-align:center; } .tabTltle ul li{ float:left; position:relative; background:#fefefe; background:-webkit-gradient(linear,left top,left bottom, from(#fefefe), to(#ededed)); padding:7px 15px; border:1px #ddd solid; margin-right:-1px; cursor:pointer; } .tabTltle ul li.active{ background:#fff; font-weight: bold; } .clearfix{ } .clearfix:after{ display:block; clear:both; overflow:hidden; content:""; } .tabConn{ border:1px #eee solid; position:relative; height:100px } .tabConn div{ position:absolute; opacity:0; filter:alpha(opacity=0); padding:5px; text-align:center; width:100%; } .tabConn div.current{ opacity:1; filter:alpha(opacity=100); } jQuery写的选项卡: aaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb cccccccccccccccccccccccccccccccc ddddddddddddddddddddddddddddd
- 标题一
- 标题二
- 标题三
- 标题四
是不是简单了好多!
以上所述就是本文的全部内容了,希望大家能够喜欢。



