HTML + JS + CSS tab effect [Collection and arrangement]

Source: Internet
Author: User

1. Simulate the Windows Tab

 <HTML> <br/> <pead> <br/> <SCRIPT> <br/> var num = 4; // here is the number of tabs added <br/> var carnum = 2 + num </P> <p> function document. onselectstart () {<br/> var OBJ = event. srcelement <br/> If (obj. tagname = "span") {<br/> return false; <br/>}</P> <p> function document. onmousedown () {<br/> var OBJ = event. srcelement <br/> var pobj = obj. parentelement. ID; <br/> If (obj. classname = "span") {<br/> for (I = 1; I <carnum; I ++) {<br/> If (pobj = ("B TN "+ I) {<br/> document. all ("TD" + I ). style. backgroundcolor = "menu" <br/> document. all ("BTN" + I ). style. height = 20 <br/> content (I) <br/>} else {<br/> document. all ("TD" + I ). style. backgroundcolor = "white" <br/> document. all ("BTN" + I ). style. height = 18 <br/>}</P> <p> function content (I) {<br/> // The menu name <br/> mnuitem (1, "item 1") <br/> mnuitem (2, "Image World ") <br/> mnuitem (3, "third content") <br/> mnuitem (4, "table") <br/> Mn Uitem (5, "scroll subtitle") <br/> // end <br/> if (I = 1) {<br/> span1.innerhtml = "<input type = radio checked name = A> male <input name = A type = radio> female <br>" <br/> + "< input> <br> <input type = submit> "<br/>}< br/> if (I = 2) {<br/> span1.innerhtml = "}< br/> if (I = 3) {<br/> span1.innerhtml = "<p> third content </p>" <br/>}< br/> if (I = 4) {<br/> span1.innerhtml = "<Table bord ER = 1 width = 100%> <TD> fourth content, table </TD> </tr> "<br/> +" <tr> <TD> aaaaaaaa </TD> </tr> "<br/> +" <tr> <TD> bbbbbbbbbb </TD> </tr> "<br/> +" <tr> <TD> ccccccccc </TD> </tr> </table>" <br/>}< br/> if (I = 5) {<br/> span1.innerhtml = "<marquee>" <br/> + "this is the fifth content" <br/> + "la ..? </Marquee> "<br/>}</P> <p> function mnuitem (I, con) {<br/> document. all ("menuname" + I ). innertext = con <br/>}< br/> </SCRIPT> </P> <p> <style> TD {font-size: 9pt} <br/>. SPAN {<br/> cursor: default; <br/> padding-left: 5; <br/> padding-top: 2; <br/> padding-Right: 5; <br/> padding-bottom: 0; <br/> width: 100%; <br/> Height: 100%; <br/>}< br/> </style> <br/> <title> </title> <br/> <meta http-equiv = "Content-Type" content = "Tex T/html; charset = gb2312 "> <br/> </pead> </P> <p> <body bgcolor = ffffff onload = content (1) onselectstart = "Return false"> <br/> <p> <br/> <Table width = 0 onselectstart = "Return false" bgcolor = menu align = center> <br/> <tr> <br/> <TD> <br/> <Table cellpadding = 0 cellspacing = 0 onselectstart = "Return false"> <br/> <tr Height = 20> <br/> <TD valign = bottom> <br/> <Table cellspacing = 0 cellpadding = 0 bgcolor = menu> <br/> <tr> <br/> <TD width = 1 Height = 1> </TD> <TD width = 1 Height = 1> </TD> <br/> <TD bgcolor = white> </TD> <TD> </TD> <br/> </tr> <br/> <TD width = 1 Height = 1> </TD> <br/> <TD width = 1 Height = 1 bgcolor = white> </TD> <br/> <TD> </TD> <br/> <TD bgcolor = Black> </TD> <br/> <TD> </TD> <br/> </tr> <br/> <tr> <br/> <TD width = 1 bgcolor = white> </TD> <br/> <TD width = 1 Height = 1> </TD> <br/> <TD id = btn1 height = 20> <SPAN class = span id = menun Ame1> </span> </TD> <br/> <TD width = 1 bgcolor = gray> </TD> <br/> <TD bgcolor = black width = 1> </TD> <br/> </tr> <br/> <TD bgcolor = white> </TD> <br/> <TD colspan = 4 Height = 1 bgcolor = menu id = TD1> </TD> <br/> </tr> <br/> </table> <br/> </TD> <br/> <SCRIPT> <br/> for (I = 2; I <carnum; I ++) {<br/> tdbody = "<TD valign = bottom>" <br/> tdbody + = "<Table cellspacing = 0 cellpadding = 0 bgcolor = menu>" <br/> tdbody + = "<tr>" <br/> tdbo Dy + = "<TD width = 1 Height = 1> </TD>" <br/> tdbody + = "<TD width = 1 Height = 1> </TD> "<br/> tdbody + =" <TD bgcolor = white> </TD> "<br/> tdbody + =" <TD> </TD> "<br /> tdbody + = "<TD> </TD>" <br/> tdbody + = "</tr>" <br/> tdbody + = "<tr>" <br/> tdbody + = "<TD width = 1 Height = 1> </TD>" <br/> tdbody + = "<TD width = 1 Height = 1 bgcolor = white> <// TD> "<br/> tdbody + =" <TD> </TD> "<br/> tdbody ++ =" <TD bgcolor = Black> <// TD> </TD> "<br/> tdbody + =" <// Tr> "<br/> tdbody + =" <tr> "<br/> tdbody + =" <TD width = 1 bgcolor = white> </TD> "<br /> tdbody + = "<TD width = 1 Height = 1> </TD>" <br/> tdbody + = "<TD id = BTN" + I + "height = 18> <SPAN class = span id = menuname "+ I +"> </span> </TD> "<br/> tdbody + =" <TD width = 1 bgcolor = gray> </TD> "<br/> tdbody + =" <TD bgcolor = black width = 1> </TD> "<br/> tdbody + = "<// tr>" <br/> tdbody + = "<tr>" <br/> tdbody + = "<TD bgcolor = white> </TD>" <br/> tdbody + = "<TD Colspan = 4 Height = 1 bgcolor = white id = TD "+ I +"> </TD> "<br/> tdbody + =" </tr> "<br /> tdbody + = "<// table>" <br/> tdbody + = "</TD> "; <br/> document. write (tdbody) <br/>}< br/> </SCRIPT> </P> <p> <TD style = "border-bottom: 1 white solid "width = 50> </TD> <br/> </tr> <br/> </table> <br/> <Div style =" padding: 10; width: 100%; Height: 200; border-left: 1 white solid; border-Right: 2 outset; border-bottom: 2 outset "> <br/> <span id = Span 1> </span> <! -- Here is the content --> <br/> </div> <br/> </TD> <br/> </tr> <br/> </table> <br /> </body> <br/> </ptml> <br/>

 

2. Simulate Taobao

 

<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <br/> <HTML lang = "US-en"> <br/> <pead> <br/> <title> CSS tab (HTML component) </title> <br/> <LINK rel = "shortcut icon" href = "favicon. ICO "type =" image/X-icon "/> <br/> <meta http-equiv =" Content-Type "content =" text/html; charset = gb2312 "/> <br/> <meta name =" keywords "content =" "/> <br/> <meta name =" de Contents "content =" "/> <br/> <style type =" text/CSS "> <br/> Div. card Div {background-color: # ff8000; float: Left; padding: 1px; padding-bottom: 0; clear: Both; width: 405px;} <br/> Div. card A {color: black; font-size: 14px; text-Decoration: none; float: Left; width: 100px; text-align: center; Background-color: white; margin-Right: 1px ;}< br/> Div. card Div. home. home {Font: normal bold 14px/1.5; ;}< br/> Div. Card Div. international. international {Font: normal bold 14px/1.5; ;}< br/> Div. card Div. sport. sport {Font: normal bold 14px/1.5; ;}< br/> Div. card Div. finance. finance {Font: normal bold 14px/1.5; ;}< br/> Div. card Div. content {background-color: White; Border: 1px solid # ff8000; Height: 100px ;} <br/> </style> <br/> <SCRIPT type = "text/JavaScript"> <br/> var SHQ ={}< br/> SHQ. cmenu = Function (e) <br/>{< br/> var E = Window. event? Window. event. srcelement: e.tar get; <br/> If (/a/I. test (E. tagname) {<br/> E. parentnode. classname = E. classname; <br/> E. parentnode. nextsibling. innerhtml = E. innerhtml; <br/> e.parentnode.nextsibling.style.css text = 'border-top: none'; <br/> E. blur (); <br/>}< br/> </SCRIPT> <br/> </pead> <br/> <body> <br/> <Div class = "card"> <br/> <Div onclick = "SHQ. cmenu (event) "> <br/> <a href =" # "class =" home "> China </a> <br/> <A href = "#" class = "international"> international </a> <br/> <a href = "#" class = "sport"> sports </a> <br/> <a href = "#" class = "finance"> Finance </a> <br/> </div> <Div class = "content"> </ div> <br/> </div> </P> <p> <Div class = "card"> <br/> <Div onclick = "SHQ. cmenu (Event) "> <br/> <a href =" # "class =" home "> domestic </a> <br/> <a href =" # "class =" international"> international </a> <br/> <a href = "#" class = "sport"> sports </a> <br/> <a href = "#" Class = "finance"> Finance </a> <br/> </Div> <Div class = "content"> </div> <br/> </div> </P> <p> <Div class = "card"> <br /> <Div onclick = "SHQ. cmenu (Event) "> <br/> <a href =" # "class =" home "> domestic </a> <br/> <a href =" # "class =" international"> international </a> <br/> <a href = "#" class = "sport"> sports </a> <br/> <a href = "#" Class = "finance"> Finance </a> <br/> </div> <Div class = "content"> </div> <br/> </div> <br /> </body> <br/> </ptml> <script language = "JavaScript"> <br/> var now = new date (); <Br/> document. Write (" "); <br/> </SCRIPT> <br/> <NoScript> <br/> <br/> </ noScript> <br/>

 

 

 

3. Clear Style

(From http://bbs.blueidea.com/thread-2795660-1-1.html)

 

<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en"> <br/> <! -- <Br/> retain the original author When referencing, respect any original author, and promote the Internet process in China <br/> Editor: weasle </P> <p> http://www.hxcgw.com </P> <p> Email: weasle@163.com <br/> QQ: 112011531 <br/> --> <br/> <HTML xmlns = "http://www.w3.org/1999/xhtml"> <br/> <pead> <br/> <meta http-equiv = "Content-Type "content =" text/html; charset = gb2312 "/> <br/> <title> concise tab </title> <br/> <style type =" text/CSS "> <br/> <! -- <Br/> body, Div, UL, Li {<br/> padding: 0; <br/> text-align: center; <br/>}< br/> body {<br/> Font: 12px ""; <br/> text-align: center; <br/>}< br/> A: link {<br/> color: # 00f; <br/> text-Decoration: none; <br/>}< br/> A: visited {<br/> color: # 00f; <br/> text-Decoration: none; <br/>}< br/> A: hover {<br/> color: # c00; <br/> text-Decoration: underline; <br/>}< br/> ul {list-style: none;} <br/>/* Tab 1 */<br/> # tab1 {<Br/> width: 460px; <br/> margin: 0px; <br/> padding: 0px; <br/> margin: 0 auto ;} <br/>/* Tab 2 */<br/> # tab2 {<br/> width: 576px; <br/> margin: 0px; <br/> padding: 0px; <br/> margin: 0 auto ;}< br/>/* menu class */<br/>. menubox {<br/> width: 100%; <br/> Background: URL (http://www.hxcgw.com/bbs/upfile/20079299441652.gif); <br/> Height: 28px; <br/> line-Height: 28px; <br/>}< br/>. menubox ul {<br/> margin: 0px; <br/> padding: 0px; <B R/>}< br/>. menubox Li {<br/> float: Left; <br/> display: block; <br/> cursor: pointer; <br/> width: 114px; <br/> text-align: center; <br/> color: #949694; <br/> font-weight: bold; <br/>}< br/>. menubox Li. hover {<br/> padding: 0px; <br/> Background: # FFF; <br/> width: pixel PX; <br/> border-left: 1px solid # a8c29f; <br/> border-top: 1px solid # a8c29f; <br/> border-Right: 1px solid # a8c29f; <br/> Background: URL (HT TP: // www.hxcgw.com/bbs/upfile/200792994426548.gif); <br/> color: #739242; <br/> font-weight: bold; <br/> Height: 27px; <br/> line-Height: 27px; <br/>}< br/>. contentbox {<br/> clear: Both; <br/> margin-top: 0px; <br/> border: 1px solid # a8c29f; <br/> border-top: none; <br/> Height: 181px; <br/> text-align: center; <br/> padding-top: 8px; <br/>}< br/> --> <br/> </style> <br/> <SCRIPT> <br/> <! -- <Br/>/* first, second, and second */<br/> function settab (name, cursel, n) {<br/> for (I = 1; I <= N; I ++) {<br/> var menu = document. getelementbyid (name + I); <br/> var con = document. getelementbyid ("con _" + name + "_" + I); <br/> menu. classname = I = cursel? "Hover": ""; <br/> con. style. Display = I = cursel? "Block": "NONE "; <br/>}< br/> // --> <br/> </SCRIPT> <br/> </pead> <br/> <body> <br/> <Div id = "tab1"> <br/> <Div class = "menubox"> <br/> <ul> <br/> <li id = "one1" onclick = "settab ('one ', 1, 4) "> News 1 </LI> <br/> <li id =" one2 "onclick =" settab ('one', 2, 4) "> News 2 </LI> <br/> <li id =" one3 "onclick =" settab ('one', 3,4) "> News 3 </LI> <br/> <li id =" one4 "onclick =" settab ('one', 4,4) "> News 4 </LI> <br/> </ul> <br/> </div> <br/> <Div class =" contentbox "> <br/> <Div id = "con_one_1"> News list 1 </div> <br/> <Div id = "con_one_2" style = "display: none "> News list 2 </div> <br/> <Div id =" con_one_3 "style =" display: none "> News list 3 </div> <br/> <Div id =" con_one_4 "style =" display: none "> News list 4 </div> <br/> <Div ID = "tab2"> <br/> <Div class = "menubox"> <br/> <ul> <br/> <li id = "two1" onclick = "settab ('two ', 1, 4) "> News 1 </LI> <br/> <li id =" two2 "onclick =" settab ('two', 2, 4) "> News 2 </LI> <br/> <li id =" two3 "onclick =" settab ('two', 3,4) "> News 3 </LI> <br/> <li id =" two4 "onclick =" settab ('two', 4, 4) "> News 4 </LI> <br/> </ul> <br/> </div> <br/> <Div class =" contentbox "> <br/> <Div id = "con_two_1"> News list 1 </div> <br/> <Div id = "con_two2" style = "display: none "> News list 2 </div> <br/> <Div id =" con_two_3 "style =" display: none "> News list 3 </div> <br/> <Div id =" con_two_4 "style =" display: none "> News list 4 </div> <br/> </body> <br/> </ HTML>

 

 

4. Clear Style

 

 <! Doctype HTML public "-// W3C // dtd html 4.01 transitional // en" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd"> <br/> <HTML xmlns = "http://www.w3.org/1999/xhtml"> <pead> <title> adaptive width tab </title> <br/> <meta http-equiv = Content-Type content = "text/html; charset = gb2312 "> <br/> <style type = text/CSS> body {<br/> font-size: 14px; font-family: "" <br/>}< br/> ol Li {<br/> margin: 8px <br/>}< br/> # Con {<br/> font-size: 12px; <br/> margin: 0px auto; </P> <p> width: 600px <br/>}< br/> # tags {<br/> padding-Right: 0px; <br/> padding-left: 0px; <br/> padding-bottom: 0px; <br/> margin: 0px 0px 0px 10px; <br/> width: 400px; <br/> padding-top: 0px; <br/> Height: 23px <br/>}< br/> # tags Li {<br/> Background: # afeeee; <br/> float: left; <br/> margin-Right: 1px; <br/> list-style-type: none; <br/> height: 23px <br/>}< br/> # tags Li a {<br/> padding-Right: 10px; <br/> padding-left: 10px; <br/> Background: # b0e0e6; <br/> float: Left; <br/> padding-bottom: 0px; <br/> color: #999; <br/> line-Height: 23px; <br/> padding-top: 0px; <br/> Height: 23px; <br/> text-Decoration: none; <br/>}< br/> # tags Li. emptytag {<br/> Background: None transparent scroll repeat 0% 0%; <br/> width: 4px <br/>}< br/> # tags Li. selecttag {<br/> background-position: Left top; <br/> margin-bottom:-2px; <br/> position: relative; <br/> height: 25px <br/>}< br/> # tags Li. selecttag A {<br/> background-position: Right top; <br/> color: #000; <br/> line-Height: 25px; <br/> height: 25px <br/>}< br/> # tagcontent {<br/> border-Right: # aecbd4 1px solid; <br/> padding-Right: 1px; <br/> border-top: # aecbd4 1px solid; <br/> padding-left: 1px; <br/> padding-bottom: 1px; <br/> border-left: # aecbd4 1px solid; <br/> padding-top: 1px; <br/> border-bottom: # aecbd4 1px solid; <br/> background-color: # FFF; <br/>}< br/>. tagcontent {<br/> padding-Right: 10px; <br/> display: none; <br/> padding-left: 10px; <br/> padding-bottom: 10px; <br/> width: 576px; <br/> color: #474747; <br/> padding-top: 10px; <br/> height: 250px <br/>}< br/> # tagcontent Div. selecttag {<br/> display: block <br/>}< br/> </style> <br/> <meta content = "mshtml 6.00.2800.1589" name = generator> </pead> <br/> <body> <br/> <Div id = con> <br/> <ul id = tags> <br/> <li> <a onclick = "selecttag ('tagcontent0 ', this) "href =" javascript: void (0) "> tag 1 </a> </LI> <br/> <li class = selecttag> <a onclick =" selecttag ('tagcontent1', this) "href =" javascript: void (0) "> tag 2 </a> </LI> <br/> <li> <a onclick =" selecttag ('tagcontent2 ', this) "href =" javascript: void (0) "> adaptive width label </a> </LI> <br/> </ul> <br/> <Div id = tagcontent> <br/> <Div class = tagcontent id = tagcontent0> content of the first tag of 100 tutorial Network </div> <br/> <Div class = "tagcontent selecttag" id = tagcontent1> content of the second tag </ div> <br/> <Div class = tagcontent id = tagcontent2> <a href = 'HTTP: // www.100date.cn 'title = 'webpage Design'> 100-day Webpage Design Network </a> content of the third tag </div> <br/> </div> <br/> <SCRIPT type = text/JavaScript> <br/> function selecttag (showcontent, selfobj) {<br/> // operation tag <br/> var tag = document. getelementbyid ("tags "). getelementsbytagname ("Li"); <br/> var taglength = tag. length; <br/> for (I = 0; I <taglength; I ++) {<br/> tag [I]. classname = ""; <br/>}< br/> selfobj. parentnode. classname = "selecttag"; <br/> // operation content <br/> for (I = 0; j = document. getelementbyid ("tagcontent" + I); I ++) {<br/> J. style. display = "NONE"; <br/>}< br/> document. getelementbyid (showcontent ). style. display = "Block"; <br/>}< br/> </SCRIPT> <br/> </body> <br/> </ptml> <br/>

 

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.