Awesome Card Flip Animation using CSS & JavaScript - Easy tutorial

Поделиться
HTML-код
  • Опубликовано: 23 сен 2020
  • Learn how to create an awesome animating card flip with only the use of HTML, CSS and JavaScript. You can use this in games, website reveal cards or even for a portfolio piece!
    Github repo: github.com/TylerPottsDev/card...
    // JOIN THE DISCORD
    / discord
    // FOLLOW ME ON TWITTER
    / tyler_potts_
    // INTERESTED IN GAME DEV?
    Game development channel: / muddywolf
    // CHECK OUT MY GAME
    play.google.com/store/apps/de...
    // SUPPORT MY GRIND
    Patreon: / tyler_potts_
    LIKE // SUBSCRIBE // SHARE // COMMENT
    #CSS #JavaScript

Комментарии • 129

  • @qwarlockz8017
    @qwarlockz8017 2 года назад +3

    This was a really great vid. It was clear and easy to follow and sort of set a lot of things in place. Thanks for the help and great work!

  • @boneykingofsomewhere
    @boneykingofsomewhere Год назад

    Just found your videos and I love them! your videos are short-ish and well explained, these are good things. 12 hour react course is just a bit much from others lol

  • @prathamgenius
    @prathamgenius 2 года назад

    Awesome buddy!!!! I used it for my Ecommerce Website.....Loved this.....Well explained

  • @maefaemusic
    @maefaemusic Год назад

    Great vid! Thank you so much. This is perfect for the project I'm working on

  • @bedtimehorrorstoryyoutube
    @bedtimehorrorstoryyoutube 7 месяцев назад

    Freaking great! Crystal clear! Thank you !!

  • @manohisoa
    @manohisoa Год назад

    Thanks a lot for this video! It was really helpful. Very simple and straightforward.

  • @iselaregain9301
    @iselaregain9301 3 года назад +1

    Tyler, this tutorial is so awesome. You are awesome!!!

  • @kajberg9111
    @kajberg9111 3 года назад +1

    looked on alot of these videos and liked this the most. Thanks man for a really good tutorial.

  • @kristofbalinth2071
    @kristofbalinth2071 2 года назад +1

    You deserve millions of subs. I accidently found this channel but the content is golden so I'm staying :)
    Thanks and keep up the good work.
    Superb content and presenting format.

  • @d.ashley879
    @d.ashley879 2 года назад

    Did anyone else get overlapping text on the card when you used "Lorem" or any other longer text in the tag?

  • @estebanpedroguerravidal8336
    @estebanpedroguerravidal8336 Год назад

    I love it. Thanks 👌

  • @wanishoaib_
    @wanishoaib_ 3 года назад +1

    i stumbled on this video and i have to subscribe

  • @linhbebu912
    @linhbebu912 2 года назад +1

    A very good tutorial, everything is very clear. Thanks a lot!!!

  • @aloobre
    @aloobre 3 года назад +4

    More of this, really like these easy tutorials..so good for inspiration

    • @TylerPotts
      @TylerPotts  3 года назад +1

      Thank you! Will do!

    • @abdullahboston6963
      @abdullahboston6963 3 года назад

      You probably dont give a shit but if you guys are stoned like me during the covid times you can stream all the latest movies and series on instaflixxer. Been streaming with my brother for the last months =)

    • @franciscohen1299
      @franciscohen1299 3 года назад

      @Abdullah Boston Definitely, have been watching on InstaFlixxer for since november myself :)

  • @roshdyessam3480
    @roshdyessam3480 2 года назад +1

    I really laughed when I found we got the same theme, cool video btw

  • @itsnotaperfectgame4899
    @itsnotaperfectgame4899 2 года назад +1

    i love u, thx!!! i need this

  • @malamhari_
    @malamhari_ 3 года назад +2

    Thanks for this, learn so much

  • @mcm4981
    @mcm4981 3 года назад +1

    Great vid, I do appreciate. Just what I needed to see...

  • @petipois28
    @petipois28 3 года назад +4

    I used this as a base to make an ionic vue simple card game. Thank you

  • @bepd
    @bepd 3 года назад +1

    Loved this

  • @gabriel_lk
    @gabriel_lk 10 месяцев назад

    Thanks a lot!

  • @Dxaskotek
    @Dxaskotek 2 года назад +1

    Nice video, everything works! Thanks a lot ;)

  • @andrearivera7065
    @andrearivera7065 Год назад

    Thanks, this was very helpfull ♥

  • @limpmebrasil4991
    @limpmebrasil4991 Год назад

    Hey great video, thank you!
    Would it be possible to flip the card clicking a button instead of tapping the card?

  • @hvariawa
    @hvariawa 3 года назад +1

    Brilliant tutorial

  • @santiagoramirez5507
    @santiagoramirez5507 3 года назад +2

    Thank you so much!! Using this technic I'm gonna make prettier websites!
    Greetings from Chile!!

  • @ricardoreales7316
    @ricardoreales7316 Год назад

    excellent code... very useful... thank you very much

  • @samjoseph5718
    @samjoseph5718 Год назад

    Great video!

  • @Sol-ty5nx
    @Sol-ty5nx 2 года назад +1

    I love it! thank you. Greetings from Argentina

    • @TylerPotts
      @TylerPotts  2 года назад

      Thank you for watching! Hello in Argentina!

  • @yevgenia7785
    @yevgenia7785 3 года назад +1

    Thank you so much!

  • @stefanpfadt4353
    @stefanpfadt4353 2 года назад

    Hey cool ☺ Any chance to start the flip when you toggle a switch? (e.g. monthly to yearly)

  • @lucasdahl1118
    @lucasdahl1118 2 года назад +1

    OutStanding!

  • @duck_it
    @duck_it 3 года назад +1

    I want more............ Thank you so much.

  • @kaderlakhdar5735
    @kaderlakhdar5735 3 года назад +2

    Lovely tutorial , keep on the hard work, it would be nicer to have your server window open on the side , this helps understand better the process and notice changes at ones it happens 👏👏

  • @nestorfontalvo1061
    @nestorfontalvo1061 3 года назад +1

    Javascript doesn't stop to amaze me

  • @DllacyLimaJr
    @DllacyLimaJr Год назад

    Muito bom o vídeo parabéns

  • @dowelg1071
    @dowelg1071 2 года назад

    is there a way to make the container thicker on the side view when flipped?

  • @ezebado
    @ezebado 2 года назад +1

    Wow! Amazing video Tyler ! Thank you so much for sharing. Is it another video explaining how is the process if I want to create more flashcards ? Like 100 for example. I would like to create flashcards to study. Thank you in advance. !

    • @TylerPotts
      @TylerPotts  2 года назад +2

      Hey E.B, a lot of people have asked for this so I'm going to create another video explaining how you can create multiple flip cards on a single page!

    • @ezebado
      @ezebado 2 года назад +1

      @@TylerPotts That's will be great Tyler! Thank you so much :)

  • @huckerxxx
    @huckerxxx 2 года назад +1

    Hello! Thanks for this great tutorial. Im not much of a programmer so I have one problem. When I copy whole div with class card to have 2 cards with diferent descriptions, one/first can flip and the other cant. What should I change in js to have both cards flip?

    • @thomassavino3813
      @thomassavino3813 Год назад

      I'm having the exact issue. I was hoping there'd be a reply.

    • @richardala3784
      @richardala3784 Год назад

      @@thomassavino3813 use for each in javascript

  • @palashxm
    @palashxm 3 года назад +1

    Wow 👍

  • @user-xk2dj4zi2p
    @user-xk2dj4zi2p 11 месяцев назад

    Thanks a lot, brother but can you please let me know How I can add multiple cards on a single page.

  • @tamaskosa3283
    @tamaskosa3283 3 года назад +1

    Easy and effective! I used it for my interview work! Thanks a lot!

    • @TylerPotts
      @TylerPotts  3 года назад +1

      Glad it helped!

    • @tamaskosa3283
      @tamaskosa3283 3 года назад

      @@TylerPotts The markup & css is simple enough to easily understand the mechanics behind it. However I still don't know how the css "knows" which html elements to use for card front and back sides.
      Is it because you set "transform-style:preserve-3d;" on an HTML element which MUST have exactly 2 children of which the first will be displayed on default and the second after the transformation?
      The mechanic goes hidden behind the scenes and I'd like to understand what's happening.
      Thanks again! 🙂

  • @parkerthomson1447
    @parkerthomson1447 Год назад

    Would someone happen to know why the back of the card is in the correct color but the side with all the content is a light gray? This is from me trying to learn and follow along I dont see what I messed up

  • @user-gw6hy1md4b
    @user-gw6hy1md4b 2 года назад

    i want to make 6 cards on the same page but just copy and paste the code does not work i tried some other things but none of them worked, how can i do ?

  • @slendermann7610
    @slendermann7610 3 года назад +1

    Hi, this tutorial was really helpful!! everything seems to work perfectly using chrome, but... using Safari instead, the property -webkit-backface-visibility: hidden; seems to work only on the front face of the card, while when the card is flipped i can see through the back face and i dont know how to fix that. is there any solution to this weird problem? :/

    • @TylerPotts
      @TylerPotts  2 года назад

      I'm unsure I'd have to take a further look. Sorry.

    • @jesy1732
      @jesy1732 2 года назад

      M
      Mm

  • @shubkale376
    @shubkale376 3 года назад

    12:37 line.76 can you please elaborate more on the " .card__header::after "

    • @TylerPotts
      @TylerPotts  2 года назад

      What do you want me to explain?

  • @Michael-yb1bm
    @Michael-yb1bm 2 года назад +1

    Hey! Sorry for asking, but i have a short question. How do i change the js, so that multiple cards would work?

    • @TylerPotts
      @TylerPotts  2 года назад +1

      It's hard to explain over text but you need to use a querySelectorAll and loop through each one then apply the events

    • @Michael-yb1bm
      @Michael-yb1bm 2 года назад

      @@TylerPotts yeah so thanks for answering so fast. I know, that I have to use querySelctorAll and I already tried it but somehow my code doesn't work.
      And btw. great tutorial
      My code:
      let card = document.querySelectorAll(".card__inner");
      card.forEach((link) => {
      card.addEventListener('click', function(e) {
      this.classList.toggle('is-flipped');
      });
      });

    • @TylerPotts
      @TylerPotts  2 года назад +2

      Instead of card.addevent try link.addevent your still referencing the list of cards instead of the individual one!

    • @Michael-yb1bm
      @Michael-yb1bm 2 года назад +1

      ​@@TylerPotts Oh finally it works! I literally can't say thank you enough

    • @vitoriaaguiar3379
      @vitoriaaguiar3379 2 года назад +7

      Hi, if u replace the js code for this one, it will work
      ´´const card = document.querySelectorAll(".card__inner");
      function flipCard() {
      this.classList.toggle('is-flipped');
      }
      card.forEach((card) => card.addEventListener("click", flipCard));´´

  • @zepherscotty
    @zepherscotty 11 месяцев назад

    This is fantastic, but how come I can't copy it & make more than one? When I try to make a second card & either try to add a ".card__inner2" for example to the Javascript, It doesn't work, or if I copy & make a completely new JavaScript code & add ".card__inner2" to it's own version of the Javacode, it makes both cards stop working. I know this is 3 years old but I would love to know why.

  • @sanjaybalaji9367
    @sanjaybalaji9367 2 года назад +1

    Could anyone explain me where is_flipped is declared as class in html., because he is calling it in css and also added it in JS. Please explain

    • @TylerPotts
      @TylerPotts  2 года назад

      It gets applied to the ".card__inner" div via javascript but is not declared in the HTML it is only set via JavaScript.

  • @w.gene28
    @w.gene28 9 месяцев назад

    i know its been two years but now i am here and i actually followed the whole video and fix some of my mistakes but i cannot seem to figure out why my p tag is taking a limited amount of text and whenever its exceed and number of lines it all crashes and scramble into each other , like its a total mess. Please help.

  • @doublevizzion
    @doublevizzion Год назад

    I keep getting cannot read properties of null (reading 'addeventlistener')

  • @vitoriaaguiar3379
    @vitoriaaguiar3379 2 года назад +1

    How can I put multiple cards in row? Next to each other?

    • @TylerPotts
      @TylerPotts  2 года назад

      You need to select all elements and not just thebone

  • @eugeneskrypnyk7396
    @eugeneskrypnyk7396 2 года назад +1

    On the site, you need to turn over 8 different cards, but it works only on the very first one. Why?

    • @TylerPotts
      @TylerPotts  2 года назад +1

      That's because we only target 1 card using querySelector if you want to select multiple you need to use querySelectorAll then loop through the results and apply the event listeners

    • @eugeneskrypnyk7396
      @eugeneskrypnyk7396 2 года назад

      @@TylerPotts thx)

  • @imanbenetlewis6365
    @imanbenetlewis6365 2 года назад

    Is there a way to do this without the code? Like an app or a beginner friendly version?

    • @TylerPotts
      @TylerPotts  2 года назад

      Umm I only ever work with code so I don't know

  • @sevenwoleks4658
    @sevenwoleks4658 Год назад

    plz tell a tutorial about html and css to learn from basic
    tnx

  • @janina1240
    @janina1240 Год назад +1

    Hey, how would I make this work for more than one card?

    • @TylerPotts
      @TylerPotts  Год назад

      Instead of selecting one card you'd need to select multiple with something like "querySelectorAll" then loop through and apply the same code - I hope that helps.

  • @elschilling
    @elschilling Год назад

    😍🤗

  • @oguzozdemir8886
    @oguzozdemir8886 Год назад

    Good job Tyler. I would also suggest adding...
    body { overflow: hidden; }
    .card { margin-top:50px; }
    Also thank you...

  • @mikheilrukhadze8782
    @mikheilrukhadze8782 2 года назад

    its not working on me can u help?
    on call or something

  • @alquran549
    @alquran549 6 месяцев назад

    how to change image in this code? please help meeeeeeeeeeeeeeeeeeeeeeeeee

  • @sahajranipa
    @sahajranipa 3 года назад +1

    can you please provide code files? I want to use them as for my reference bro.

    • @TylerPotts
      @TylerPotts  2 года назад

      The link is in the description ? :)

  • @romannovak375
    @romannovak375 3 года назад +2

    hi thanks for the tutorial
    if I add another card it doesn't work it please help XD

    • @TylerPotts
      @TylerPotts  3 года назад +1

      You would need to change the document.querySelector to document.querySelectorAll and then loop through the results...

    • @romannovak375
      @romannovak375 3 года назад +3

      const card = document.querySelectorAll(".card__inner");
      function flipCard() {
      this.classList.toggle('is-flipped');
      }
      card.forEach((card) => card.addEventListener("click", flipCard));
      thx works XD

    • @TylerPotts
      @TylerPotts  3 года назад +1

      @@romannovak375 Woo happy you understood what you said! My comment wasn't very clear :)

  • @paulmoldovan9518
    @paulmoldovan9518 3 года назад +1

    How to stop backface to rotate if there is a link?

    • @IspittingFactzz
      @IspittingFactzz 3 года назад +1

      Hey Paul, did you find the answer to this??

    • @paulmoldovan9518
      @paulmoldovan9518 3 года назад

      @@IspittingFactzz no

    • @TylerPotts
      @TylerPotts  2 года назад +1

      Hey Paul, It's hard to explain over text but you need to check the click path to check what was clicked and if it was a link return / stop propagation... If you need further help feel free to join the discord I can help more there.

    • @paulmoldovan9518
      @paulmoldovan9518 2 года назад +1

      @@TylerPotts Hey. Thanks. Yepp its allready made.

    • @lucasdahl1118
      @lucasdahl1118 2 года назад

      @@paulmoldovan9518 Did you get it to work?

  • @factking2241
    @factking2241 2 года назад

    nyc tutorial !, can u pls tell me how to flip the page from the other side, like it is getting flipped from the side at which it is written card front, but I want it to get flipped from the other side where it is written the information....
    Please reply !, I want to know

  • @glendonphilippbaculio1811
    @glendonphilippbaculio1811 2 года назад

    how can i rotate in 1 direction?

    • @TylerPotts
      @TylerPotts  2 года назад

      I'm not sure what you mean! If you need help feel free to join the discord and as there :)

  • @JimmyDevAndGeek
    @JimmyDevAndGeek 2 года назад +1

    How can I do to place 2 or more cards?

    • @TylerPotts
      @TylerPotts  2 года назад +1

      I've been asked multiple times for this so I will probably create a revised video :)

    • @vitoriaaguiar3379
      @vitoriaaguiar3379 2 года назад +3

      Hi, if u replace the js code for this one, it will work
      ´´const card = document.querySelectorAll(".card__inner");
      function flipCard() {
      this.classList.toggle('is-flipped');
      }
      card.forEach((card) => card.addEventListener("click", flipCard));´´

    • @JimmyDevAndGeek
      @JimmyDevAndGeek 2 года назад

      @@vitoriaaguiar3379 Thanks.😁

    •  2 года назад

      @@vitoriaaguiar3379 I LOVE YOU YOU SAVED MY LIFE :')

    • @thomassavino3813
      @thomassavino3813 Год назад

      @@vitoriaaguiar3379 Thank you! Thank you! Thank you!

  • @abgthscode6326
    @abgthscode6326 2 года назад

    not wroking for multiple cards

  • @Ricardoromero4444
    @Ricardoromero4444 Год назад

    Would be nice if the tutorial showed only the flipping animation. We have to skip through the whole video just to get to the part we came to learn

  • @ranjeet5806
    @ranjeet5806 2 года назад

    Advice: instead of focusing more on styling, try to explain more about the Crux, the flipping effect, and the backface and stuff.

    • @TylerPotts
      @TylerPotts  2 года назад

      Thanks for the feedback. I'll keep that in mind for future videos