JS+CSS tab Toggle Effect Code

Source: Internet
Author: User
The code is as follows Copy Code

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
002 003 004 <meta http-equiv= "Content-type" content= "text/html;charset=gb2312"/>
005 <title>tabMenu</title>
006 <style type= "Text/css" >
007 <!--
008 body,div,ul,li{
009 margin:0 Auto;
010 padding:0;
011}
012 body{
013 font:12px "Song Body";
014 Text-align:center;
015}
016 a:link{
017 color: #000033;
018 Text-decoration:none;
019}
020 a:visited {
021 color: #000033;
022 Text-decoration:none;
023}
024 A:hover {
025 color: #c00;
026 text-decoration:underline;
027}
028 ul{
029 List-style:none;
030}
031. main{
032 Clear:both;
033 padding:8px;
034 Text-align:center;
035}
036/* First FORM * *
037 #tabs0 {
038 height:428px;
039 width:601px;
040 border:1px solid #cbcbcb;
041 background-color: #f2f6fb;
042}
043. menu0{
044 width:400px;
045}
046. Menu0 li{
047 Display:block;
048 Float:left;
049 padding:4px 0;
050 width:100px;
051 Text-align:center;
052 Cursor:pointer;
053 background: #FFFFff;
054}
055. Menu0 li.hover{
056 background: #f2f6fb;
057}
058 #main0 ul{
059 Display:none;
060}
061 #main0 ul.block{
062 Display:block;
063}
064/* Second form * *
065 #tabs1 {
066 Text-align:left;
067 width:400px;
068}
069. menu1box{
070 position:relative;
071 Overflow:hidden;
072 height:22px;
073 width:400px;
074 Text-align:left;
075}
076 #menu1 {
077 Position:absolute;
078 top:0;
079 left:0;
080 z-index:1;
081}
082 #menu1 li{
083 Float:left;
084 Display:block;
085 Cursor:pointer;
086 width:72px;
087 Text-align:center;
088 line-height:21px;
089 height:21px;
090}
091 #menu1 li.hover{
092 background: #fff;
093 border-left:1px solid #1068E3;
094 border-top:1px solid #1068E3;
095 border-right:1px solid #1068E3;
096}
097. main1box{
098 Clear:both;
099 margin-top:-1px;
border:1px solid #1068E3;
height:186px;
102 width:390px;
103}
ul{#main1
Display:none;
106}
ul.block{#main1
108 Display:block;
109}
110/* Third form * *
menu2box{.
112 position:relative;
113 Overflow:hidden;
114 height:22px;
width:400px;
116 Text-align:left;
117 background: #FFFFff;
118}
119 #tabs2 {
height:200px;
121 width:400px;
122 border:1px solid #cbcbcb;
123 Background-color: #f2f6fb;
124}
#tip2 {
126 Position:absolute;
127 top:0;
128 left:0;
129 height:22px;
130 line-height:22px;
131 z-index:0;
132 width:100px;
Background: #f2f6fb;
134}
135 #menu2 {
136 Position:absolute;
137 top:0;
138 left:0;
139 Z-index:1;
140}
li{#menu2
Display:block;
143 Float:left;
144 PADDING:4PX 0;
145 width:100px;
146 Text-align:center;
147 Cursor:pointer;
148}
149-->
</style>
151 <script>
152 <!--
153/* The first form of the second form replace the display style * *
154 function Settab (m,n) {
The Var Tli=document.getelementbyid ("menu" +m). getElementsByTagName ("Li");
156 var Mli=document.getelementbyid ("main" +m). getElementsByTagName ("ul");
157 for (i=0;i<tli.length;i++) {
158 tli[i].classname=i==n? " Hover ":" ";
159 mli[i].style.display=i==n? " Block ": none";
160}
161}
162/* Third form using a background layer positioning * *
163 var m3={0: "" ", 1:" Comments Content ", 2:" Technical Content ", 3:" Comments on Content "}
164 function Nowtab (m,n) {
165 if (n!=0&&m3[0]== "") M3[0]=document.getelementbyid ("Main2"). InnerHTML;
166 document.getElementById ("Tip" +m). style.left=n*100+ ' px ';
167 document.getElementById ("Main2"). Innerhtml=m3[n];
168}
169//-->
170 </script>
171 172 <body>
173 <br/>
174 <br/>
175 <!--The first form of-->
176 <div id= "Tabs0" >
177 <ul class= "menu0" id= "menu0" >
178 <li onclick= "Settab (0,0)" class= "hover" > News </li>
179 <li onclick= "Settab (0,1)" > Review </li>
180 <li onclick= "Settab (0,2)" > Technology </li>
181 <li onclick= "Settab (0,3)" > Reviews </li>
</ul>
183 <div class= "main" id= "Main0" >
184 <ul class= "block" ><li> News list </li></ul>
185 <ul><li> Review List </li></ul>
186 <ul><li> Technology List </li></ul>
187 <ul><li> Reviews List </li></ul>
188 </div>
189 </div>
190 <br/>
191 <br/>
The second form of--> <!--
193 <div id= "TABS1" >
194 <div class= "Menu1box" >
195 <ul id= "menu1" >
196 <li class= "hover" onmouseover= "Settab (1,0)" ><a href= "#" > News </a></li>
197 <li onmouseover= "Settab (1,1)" ><a href= "#" > Comments </a></li>
198 <li onmouseover= "settab (1,2)" ><a href= "#" > Technology </a></li>
199 <li onmouseover= "Settab (1,3)" ><a href= "#" > Reviews </a></li>
</ul>
201 </div>
<div class= "Main1box" >
203 <div class= "main" id= "Main1" >
204 <ul class= "block" ><li> News list </li></ul>
205 <ul><li> Review List </li></ul>
206 <ul><li> Technology List </li></ul>
207 <ul><li> Reviews List </li></ul>
</div>
209 </div>
210 </div>
211 <br/>
212 <br/>
213 <!--The third form of-->
214 <div id= "TABS2" >
215 <div class= "Menu2box" >
216 <div id= "TIP2" ></div>
217 <ul id= "MENU2" >
218 <li class= "hover" onmouseover= "Nowtab (2,0)" ><a href= "#" > News </a></li>
219 <li onmouseover= "Nowtab (2,1)" ><a href= "#" > Comments </a></li>
<li onmouseover= "Nowtab (2,2)" ><a href= "#" > Technology </a></li>
221 <li onmouseover= "nowtab (2,3)" ><a href= "#" > Reviews </a></li>
222 </ul>
223 </div>
224 <div class= "main" id= "Main2" >
225 News Content
</div>
</div>
228 </body>
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.