特效介绍
仿阿里巴巴js滑动显示不同内容的tab选项卡特效,共三行两列,滑动上去,就会显示对应的内容。
使用方法
1、在head引入下面的css代码:
01 | <style type= "text/css" > |
03 | body { margin : 0px ; border : 0px ; font-size : 12px ; background-color : #fff ;} |
04 | a:link{ color : #003278 ; text-decoration : none ;} |
05 | a:visited{ color : #003278 ; text-decoration : none ;} |
06 | a:hover{ color : #FF6600 ; text-decoration : underline ;} |
07 | #slideBox{ background : url (images/slideBox_bg.gif); height : 168px ; width : 178px ; padding-left : 5px ; padding-right : 5px ;} |
08 | #slide{ padding-top : 5px } |
09 | #slide li img{ margin-right : 3px } |
10 | #slideBox ul{ padding : 0 ; margin : 0 ; clear : both ; list-style : none ; overflow : hidden } |
11 | #slideBox li{ float : left ; font-weight : bold ; height : 37px !important ; height : 27px ;} |
12 | #slideBox li a:link,#slideBox li a:visited{ color : #000 ;} |
13 | #slideBox li a:hover{ color : #ff7300 ; text-decoration : none } |
14 | #slideBox .l{ background : url (images/slideBox_tableft.gif); width : 80px ;} |
15 | #slideBox .r{ background : url (images/slideBox_tabright.gif); width : 94px ; float : right } |
16 | #slideBox .l_h{ background : url (images/slideBox_tableft_h.gif); width : 80px ;} |
17 | #slideBox .r_h{ background : url (images/slideBox_tabright_h.gif); width : 94px ; float : right ;} |
18 | #slideBox . hide { display : none } |
19 | #slideBox .l a{ width : 52px ;} |
20 | #slideBox .r a{ width : 68px ;} |
21 | .arrow{ padding-left : 8px ; background : url (images/icon_arrow 03 _right_ 08 x.gif) no-repeat ;} |
22 | #slideBox .l a,#slideBox .r a,#slideBox .l_h a,#slideBox .r_h a{ padding-left : 24px ; display : block ; height : 100% ; padding-top : 10px ;} |
23 | .btn_zchy{ background : url (images/icon_zchy 01 _ 12 x.gif) 5px 10px no-repeat ;} |
24 | .btn_cxt{ background : url (images/icon_cxt 01 _ 12 x.gif) 5px 10px no-repeat ;} |
25 | .btn_tggs{ background : url (images/icon_tggs 01 _ 12 x.gif) 5px 10px no-repeat ;} |
26 | .btn_fbxx{ background : url (images/icon_fbxx 01 _ 12 x.gif) 5px 10px no-repeat ;} |
27 | .btn_xzmj{ background : url (images/icon_xzmj 01 _ 12 x.gif) 5px 10px no-repeat ;} |
28 | .btn_alisoft{ background : url (images/icon_alisoft 01 _ 12 x.gif) 5px 10px no-repeat ;} |
30 | #slideBox .cont_l{ float : left ; background : url (images/slideBox_conleft.gif); width : 157px ; height : 31px ; padding : 9px 7px 7px 14px ; margin-bottom : 4px ; overflow : hidden } |
31 | #slideBox .cont_r{ float : left ; background : url (images/slideBox_conright.gif); width : 157px ; height : 31px ; padding : 9px 7px 7px 14px ; margin-bottom : 4px ; overflow : hidden } |
32 | #slideBox .oneline{ line-height : 33px ;} |
2、html引入到你需要使用的地方
07 | < div class = "cont_l" id = "sc_1" > |
10 | < div class = "hide" id = "sc_2" > |
17 | < div class = "hide" id = "sc_3" > |
20 | < div class = "hide" id = "sc_4" > |
27 | < div class = "hide" id = "sc_5" > |
30 | < div class = "hide" id = "sc_6" > |
3、js代码放到您的html的</body>的前面:
01 | <script type= "text/javascript" > |
07 | var sTabList = document.getElementById( "slideBox" ).getElementsByTagName( "li" ); |
08 | for ( var i=0;i<sTabList.length;i++){ |
09 | var obj = sTabList[i].getElementsByTagName( "a" )[0]; |
10 | sTabList[i].getElementsByTagName( "a" )[0].id= "slideBtn_" +(i+1); |
11 | if (obj.addEventListener) { |
12 | obj.addEventListener( "mouseover" , overSlide, false ); |
14 | else if (obj.attachEvent) { |
15 | obj.attachEvent( "onmouseover" , overSlide ); |
20 | var srcElement = e.srcElement || e.target; |
21 | var newTabIndex=srcElement.id.replace( "slideBtn_" , "" ); |
22 | var pos = srcElement.parentNode.className; |
23 | if (newTabIndex== "" ||pos.indexOf( "_h" )!=-1) return ; |
24 | document.getElementById( "slideBtn_" +slideTabIndex).parentNode.className=document.getElementById( "slideBtn_" +slideTabIndex).parentNode.className.replace( "_h" , "" ); |
25 | document.getElementById( "sc_" +slideTabIndex).className= "hide" ; |
26 | document.getElementById( "sc_" +newTabIndex).className= "cont_" +pos; |
27 | srcElement.parentNode.className = pos+ "_h" ; |
28 | slideTabIndex=newTabIndex; |
部分素材资源来源网站,本站提供免费下载,如有侵权请联系站长马上删除!