Awesome Card Flip Animation using CSS & JavaScript - Easy tutorial

แชร์
ฝัง
  • เผยแพร่เมื่อ 18 ต.ค. 2024
  • 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/Tyl...
    // JOIN THE DISCORD
    / discord
    // FOLLOW ME ON TWITTER
    / tyler_potts_
    // INTERESTED IN GAME DEV?
    Game development channel: / muddywolf
    // CHECK OUT MY GAME
    play.google.co...
    // SUPPORT MY GRIND
    Patreon: / tyler_potts_
    LIKE // SUBSCRIBE // SHARE // COMMENT
    #CSS #JavaScript

ความคิดเห็น • 130

  • @roshdyessam3480
    @roshdyessam3480 2 ปีที่แล้ว +1

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

  • @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.

  • @petipois28
    @petipois28 3 ปีที่แล้ว +4

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

  • @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!

  • @ДаниелДианов
    @ДаниелДианов 4 หลายเดือนก่อน +1

    Great video! That was exactly what I was looking for. Thanks!

    • @TylerPotts
      @TylerPotts  4 หลายเดือนก่อน

      Glad it was helpful!

  • @aloobre
    @aloobre 4 ปีที่แล้ว +4

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

    • @TylerPotts
      @TylerPotts  4 ปีที่แล้ว +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 :)

  • @wanishoaib_
    @wanishoaib_ 3 ปีที่แล้ว +1

    i stumbled on this video and i have to subscribe

  • @kajberg9111
    @kajberg9111 3 ปีที่แล้ว +1

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

    • @TylerPotts
      @TylerPotts  3 ปีที่แล้ว

      Glad you liked it!

  • @prathamgenius
    @prathamgenius 2 ปีที่แล้ว

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

  • @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?

  • @santiagoramirez5507
    @santiagoramirez5507 3 ปีที่แล้ว +2

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

  • @bedtimehorrorstoryyoutube
    @bedtimehorrorstoryyoutube ปีที่แล้ว

    Freaking great! Crystal clear! Thank you !!

  • @iselaregain9301
    @iselaregain9301 3 ปีที่แล้ว +1

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

    • @TylerPotts
      @TylerPotts  3 ปีที่แล้ว

      Glad you think so!

  • @boneykingofsomewhere
    @boneykingofsomewhere 2 ปีที่แล้ว

    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

  • @Sol-ty5nx
    @Sol-ty5nx 2 ปีที่แล้ว +1

    I love it! thank you. Greetings from Argentina

    • @TylerPotts
      @TylerPotts  2 ปีที่แล้ว

      Thank you for watching! Hello in Argentina!

  • @manohisoa
    @manohisoa ปีที่แล้ว

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

  • @linhbebu912
    @linhbebu912 3 ปีที่แล้ว +1

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

    • @TylerPotts
      @TylerPotts  3 ปีที่แล้ว +1

      Glad it helped!

  • @maefaemusic
    @maefaemusic 2 ปีที่แล้ว

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

  • @malamhari_
    @malamhari_ 4 ปีที่แล้ว +2

    Thanks for this, learn so much

    • @TylerPotts
      @TylerPotts  4 ปีที่แล้ว

      Glad it was helpful!

  • @mcm4981
    @mcm4981 3 ปีที่แล้ว +1

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

  • @lucasdahl1118
    @lucasdahl1118 2 ปีที่แล้ว +1

    OutStanding!

  • @nestorfontalvo1061
    @nestorfontalvo1061 3 ปีที่แล้ว +1

    Javascript doesn't stop to amaze me

  • @Dxazcat
    @Dxazcat 3 ปีที่แล้ว +1

    Nice video, everything works! Thanks a lot ;)

  • @hvariawa
    @hvariawa 4 ปีที่แล้ว +1

    Brilliant tutorial

  • @Amilcar69
    @Amilcar69 3 ปีที่แล้ว +1

    i love u, thx!!! i need this

  • @duck_it
    @duck_it 4 ปีที่แล้ว +1

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

    • @TylerPotts
      @TylerPotts  4 ปีที่แล้ว +1

      Working on it!! :D

  • @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 :)

  • @bepd
    @bepd 4 ปีที่แล้ว +1

    Loved this

  • @estebanpedroguerravidal8336
    @estebanpedroguerravidal8336 2 ปีที่แล้ว

    I love it. Thanks 👌

  • @gabriel_lk
    @gabriel_lk ปีที่แล้ว

    Thanks a lot!

  • @samjoseph5718
    @samjoseph5718 2 ปีที่แล้ว

    Great video!

  • @ricardoreales7316
    @ricardoreales7316 2 ปีที่แล้ว

    excellent code... very useful... thank you very 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 👏👏

    • @TylerPotts
      @TylerPotts  3 ปีที่แล้ว +1

      Thanks, will do!

  • @MDAMANSARKAR-c5x
    @MDAMANSARKAR-c5x ปีที่แล้ว

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

  • @andrearivera7065
    @andrearivera7065 ปีที่แล้ว

    Thanks, this was very helpfull ♥

  • @limpmeacademy
    @limpmeacademy 2 ปีที่แล้ว

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

  • @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! 🙂

  • @palashxm
    @palashxm 4 ปีที่แล้ว +1

    Wow 👍

  • @stefanpfadt4353
    @stefanpfadt4353 2 ปีที่แล้ว

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

  • @zepherscotty
    @zepherscotty ปีที่แล้ว

    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.

  • @DllacyLimaJr
    @DllacyLimaJr 2 ปีที่แล้ว

    Muito bom o vídeo parabéns

  • @janina1240
    @janina1240 2 ปีที่แล้ว +1

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

    • @TylerPotts
      @TylerPotts  2 ปีที่แล้ว

      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.

  • @HosseinPi921
    @HosseinPi921 2 ปีที่แล้ว

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

  • @Michael-yb1bm
    @Michael-yb1bm 3 ปีที่แล้ว +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  3 ปีที่แล้ว +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 3 ปีที่แล้ว

      @@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  3 ปีที่แล้ว +2

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

    • @Michael-yb1bm
      @Michael-yb1bm 3 ปีที่แล้ว +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));´´

  • @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

  • @oguzozdemir8886
    @oguzozdemir8886 2 ปีที่แล้ว

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

  • @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

  • @VincentBué
    @VincentBué 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 ?

  • @dowelg1071
    @dowelg1071 2 ปีที่แล้ว

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

  • @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)

  • @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

  • @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  3 ปีที่แล้ว

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

  • @w.gene28
    @w.gene28 ปีที่แล้ว

    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.

  • @elschilling
    @elschilling 2 ปีที่แล้ว

    😍🤗

  • @doublevizzion
    @doublevizzion ปีที่แล้ว

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

  • @sanjaybalaji9367
    @sanjaybalaji9367 3 ปีที่แล้ว +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  3 ปีที่แล้ว

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

  • @shubkale376
    @shubkale376 3 ปีที่แล้ว

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

    • @TylerPotts
      @TylerPotts  3 ปีที่แล้ว

      What do you want me to explain?

  • @romannovak375
    @romannovak375 4 ปีที่แล้ว +2

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

    • @TylerPotts
      @TylerPotts  4 ปีที่แล้ว +1

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

    • @romannovak375
      @romannovak375 4 ปีที่แล้ว +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  4 ปีที่แล้ว +1

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

  • @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

  • @mikheilrukhadze8782
    @mikheilrukhadze8782 3 ปีที่แล้ว

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

  • @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  3 ปีที่แล้ว +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 3 ปีที่แล้ว +1

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

    • @lucasdahl1118
      @lucasdahl1118 2 ปีที่แล้ว

      @@paulmoldovan9518 Did you get it to work?

  • @ranjeet5806
    @ranjeet5806 3 ปีที่แล้ว

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

    • @TylerPotts
      @TylerPotts  3 ปีที่แล้ว

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

  • @alquran549
    @alquran549 11 หลายเดือนก่อน

    how to change image in this code? please help meeeeeeeeeeeeeeeeeeeeeeeeee

  • @JimmyDevAndGeek
    @JimmyDevAndGeek 3 ปีที่แล้ว +1

    How can I do to place 2 or more cards?

    • @TylerPotts
      @TylerPotts  3 ปีที่แล้ว +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 2 ปีที่แล้ว

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

  • @abgthscode6326
    @abgthscode6326 2 ปีที่แล้ว

    not wroking for multiple cards

  • @sahajranipa
    @sahajranipa 3 ปีที่แล้ว +1

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

    • @TylerPotts
      @TylerPotts  3 ปีที่แล้ว

      The link is in the description ? :)

  • @glendonphilippbaculio1811
    @glendonphilippbaculio1811 3 ปีที่แล้ว

    how can i rotate in 1 direction?

    • @TylerPotts
      @TylerPotts  3 ปีที่แล้ว

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

  • @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

  • @yevgenia7785
    @yevgenia7785 3 ปีที่แล้ว +1

    Thank you so much!