Jquery + CSS text-transform attributes implement switch tab effect

Source: Internet
Author: User
Tags lowercase uppercase letter

Css has such a good property: text-transform: uppercase.

This attribute changes the uppercase and lowercase letters of an element regardless of the text in the source document. If the value is capitalize, uppercase letters are required, but there is no explicit definition of which letters should be capitalized, depending on how the user agent identifies each "word ".

None is the default value. Defines standard text with lower-case letters and upper-case letters. Each word in capitalize text starts with an uppercase letter. Uppercase only has uppercase letters. Lowercase defines no upper-case letters and only lower-case letters. Inherit specifies that the value of the text-transform attribute should be inherited from the parent element.

All browsers support the text-transform attribute.

Note: Any version of Internet Explorer (including IE8) does not support the attribute value "inherit ".

The code is as follows: Copy code

<Html>
<Head>
<Title> Google Play's minimal tabs with CSS3 & jQuery-demo </title>
<Style>
Body {
Width: 700px;
Margin: 100px auto 0 auto;
Font-family: Arial, Helvetica;
Font-size: small;
Background-color: # eee;
Background-image: url (data: image/gif; base64, R0lGODlhCAAIAJEAAMzMzP // waaach5baehaaialaaaaiaagaaainhg4nudrogjbrsycxkaa7 );
 }

/*-------------------------------------------------*/

# Tabs {
Overflow: hidden;
Width: 100%;
Margin: 0;
Padding: 0;
List-style: none;
 }

# Tabs li {
Float: left;
Margin: 0-15px 0 0;
 }

# Tabs {
Float: left;
Position: relative;
Padding: 0 40px;
Height: 0;
Line-height: 30px;
Text-transform: uppercase;
Text-decoration: none;
Color: # fff;
Border-right: 30px solid transparent;
Border-bottom: 30px solid # 3D3D3D;
Border-bottom-color: #7779;
Opacity:. 3;
Filter: alpha (opacity = 30 );
 }

# Tabs a: hover,
# Tabs a: focus {
Border-bottom-color: #2ac7e1;
Opacity: 1;
Filter: alpha (opacity = 100 );
 }

# Tabs a: focus {
Outline: 0;
 }

# Tabs # current {
Z-index: 3;
Border-bottom-color: # 3d3d3d;
Opacity: 1;
Filter: alpha (opacity = 100 );
 }

/*-----------*/
# Content {
Background: # fff;
Border-top: 2px solid # 3d3d3d;
Padding: 2em;
/* Height: 220px ;*/
 }

# Content h2,
# Content h3,
# Content p {
Margin: 0 0 15px 0;
 } 

/* Demo page only */
# About {
Color: #999;
Text-align: center;
Font: 0.9em Arial, Helvetica;
 }

# About {
Color: #777;
 }  
</Style>
</Head>
<Body>
<Ul id = "tabs">
<Li> <a href = "#" name = "# tab1"> One </a> </li>
<Li> <a href = "#" name = "# tab2"> Two </a> </li>
<Li> <a href = "#" name = "# tab3"> Three </a> </li>
<Li> <a href = "#" name = "# tab4"> Four </a> </li>
</Ul>

<Div id = "content">
<Div id = "tab1">
<H2> Lorem ipsum sit amet <P> Praesent risus nisi, iaculis nec condimentum vel, rhoncus vel dolor. Aenean nisi lectus, varius nec tempus id, dapibus non quam. </p>
<P> Suspendisse ac libero mauris. Cras lacinia porttitor urna, vitae extends libero posuere et. Mauris turpis tortor, mollis non vulputate sit amet, rhoncus vitae purus.
<H3> Pellentesque habitant <P> Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae. </p>
</Div>
<Div id = "tab2">
<H2> Vivamus fringilla suscipit justo <P> Aenean dui nulla, egestas sit amet auctor vitae, facilisis id odio. Donec dictum gravida feugiat. </p>
<P> Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Cras presponelit et erat condimentum et volutpat lorem vehicula </p>

<P> Morbi tincidunt pharetra orci commodo molestie. Praesent ut leo nec dolor tempor eleifend. </p>
</Div>
<Div id = "tab3">
<H2> Phasellus non nibh <P> Non erat laoreet ullamcorper. Adjust magna metus, feugiat eu elementum sit amet, cursus sed diam. Curabitur posuere porttitor lorem, eu malesuada tortor faucibus sed. </p>
<H3> Duis pulvinar nibh vel urna <P> Donec purus leo, porttitor eu molestie quis, porttitor sit amet ipsum. class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. donec accumsan ornare elit id imperdiet. </p>
<P> sustmdisse ac libero mauris. Cras lacinia porttitor urna, vitae molestie libero posuere et. </p>
</Div>
<Div id = "tab4">
<H2> Cum sociis natoque penatibus <P> Magnis dis parturient montes, nascetur ridiculus mus. Nullam ac massa quis nisi porta mollis venenatis sit amet urna. Ut in mauris velit, bibsed endum turpis. </p>
<P> Nam ornare vulputate risus, id volutpat elit porttitor non. in consequat nisi vel lectus dapibus sodales. pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. praesent bibendum sagittis libero. </p>
<H3> Imperdiet sem interdum nec <P> Mauris rhoncus tincidunt libero quis fringilla. </p>
</Div>
</Div>
 
<P id = "about"> Back to <a href = "/google-play-minimal-tabs-with-css3-jquery"> article </a>/Drop me a message on <a href = "http://twitter.com/catalinred"> Twitter </a>! </P>

<Script src = "http://code.jquery.com/jquery-1.7.2.min.js"> </script>

<Script>
Function resetTabs (){
$ ("# Content> div"). hide (); // Hide all content
$ ("# Tabs a"). attr ("id", ""); // Reset id's
    }

Var myUrl = window. location. href; // get URL
Var myUrlTab = myUrl. substring (myUrl. indexOf ("#"); // For localhost/tabs.html # tab2, myUrlTab = # tab2
Var myUrlTabName = myUrlTab. substring (0, 4); // For the above example, myUrlTabName = # tab

(Function (){
$ ("# Content> div"). hide (); // Initially hide all content
$ ("# Tabs li: first a"). attr ("id", "current"); // Activate first tab
$ ("# Content> div: first"). fadeIn (); // Show first tab content
       
$ ("# Tabs a"). on ("click", function (e ){
E. preventDefault ();
If ($ (this). attr ("id") = "current") {// detection for current tab
Return
            }
Else {
ResetTabs ();
$ (This). attr ("id", "current"); // Activate this
$ (This). attr ('name'). fadeIn (); // Show content for current tab
            }
});

For (I = 1; I <= $ ("# tabs li"). length; I ++ ){
If (myUrlTab = myUrlTabName + I ){
ResetTabs ();
$ ("A [name = '" + myUrlTab + "']"). attr ("id", "current"); // Activate url tab
$ (MyUrlTab). fadeIn (); // Show url tab content
          }
        }
})()
</Script>

<! -- BSA AdPacks code -->
<Script>
(Function (){
Var bsa = document. createElement ('script ');
Bsa. async = true;
Bsa. src = 'http: // www.red-team-design.com/js/adpacks-demo.js ';
(Document. getElementsByTagName ('head') [0] | document. getElementsByTagName ('body') [0]). appendChild (bsa );
})();
</Script>
</Body>
</Html>

Effect

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.