Css3+jquery+js to do the turn-over music games

Source: Internet
Author: User
Tags jquery library

Mainly in order to practice the CSS3 3D flip function, do this little game, do more rough, but the results see.

The main use of the CSS3 code is as follows:

HTML structure:

1 <Divclass= "Container">2      <Divclass= "side">3 4         <Divclass= "Front">5           <!--Front -6         </Div>7 8         <Divclass= "Back">9           <!--Reverse -Ten         </Div> One  A      </Div> -   </Div>

The Styles for this section setting:

. Container{Perspective: +;}. Container:hover. Side{Transform:Rotatey (180deg);}. Container,. Front,. Back{width:320px;Height:480px;}. Side{transition:0.6s;/*the time it took to complete the rollover*/Transform-style:preserve-3d;/*let the child element have the effect of the rotation. */position:relative;}. Front,. Back{backface-visibility:Hidden;/*will reverse the 180-degree hidden*/position:Absolute;}. Front{Background-color:Red;}. Back{Transform:Rotatey (180deg);Background-color:Blue;}

This way, as long as the mouse is moved in. Container will happen 3D flip; this game is slightly different, is to flip after clicking, the code is as follows:
HTML structure:

1 <Divclass= "Container">2 3         <Divclass= "side">4             <Divclass= "Front"><imgsrc= "Images/face.jpg"></Div>5             <Divclass= "Back"><imgsrc= "Images/1.jpg"></Div>6         </Div>7 .../* Intermediate code ibid., omitted * /8 </Div>

JS section:
Note To introduce the jquery library,

1$(function(){2 3     varlist=$ (". Side"),4Count=0;5 6      for(vari=0;i<list.length;i++){7 8         varT=0,9Str=[],Tenp=[]; One  AList[i].flag= "OK"; -list[i].index=i; -  thelist[i].onclick=function(){ -  -             if( This. flag==NULL){ -                  This. onclick=function(){} +             } -             Else{ +  At++; atstr[t]= This. InnerHTML; -p[t]= This. Index; -                 -                if( This. flag=== "OK"){ -  -$( This). CSS ("transform", "Rotatey (180deg)")); in                     This. flag= "Error"; -  to}Else if( This. flag=== "Error"){ +$( This). CSS ("transform", "Rotatey (0deg)")); -                    This. flag= "OK"; the                 } *  $               Panax Notoginseng                if(t==2){ -  the                     if(str[1]!=str[2]){ +SetTimeout (function(){ A  the$ (list[p[1]]). CSS ("transform", "Rotatey (0deg)"); +$ (list[p[2]]). CSS ("transform", "Rotatey (0deg)"); -T=0; $                            $},500); -                      -List[p[1]].flag= "OK"; theList[p[2]].flag= "OK"; - Wuyi}Else{ thecount+=2; -list[p[1]].flag=NULL; Wulist[p[2]].flag=NULL; -  About                             if(count==list.length) { $Alert ("Congratulations on your clearance!") "); -                             } -T=0; -                     } A                  +                } the              } -           } $        the     } the  the})

CSS part of the main code has been described above, no longer repeat, the complete code, see Https://github.com/zhangyudan/js_jquery_css3-game.

Css3+jquery+js to do the turn-over music games

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.