Card Flip Effect (HTML & CSS)

แชร์
ฝัง
  • เผยแพร่เมื่อ 7 ก.ย. 2024
  • Learn how to create a 3D Card Flip Effect with HTML and CSS.
    Besides being an elegant animation, flipping cards, with content in both sides, can be a great space saver for a website.
    The minimal HTML structure and CSS styling to achieve the effect is described so that you can go ahead and add content and styling to front and back sides of the card, creating all kinds of flipping cards such as: Portfolio Cards, Profile Cards, Social Cards, Credit Cards, Business Cards, Movie Cards, Recipe Cards, Blog Cards, Product Cards, Game Cards etc.
    Initially, the card flip effect takes place on hover over the card container, only using CSS and then JavaScript is used in order to trigger the effect upon a click event.
    Code for this Project: codepen.io/Cod...
    Support the Channel 💙☕🙏
    PayPal: paypal.me/Codi...
    Suggested Videos:
    Slide-In Overlay Hover Effect (HTML & CSS): • Slide-In Overlay Hover...
    Typing Effect with HTML, CSS and JavaScript: • Typing Effect with HTM...
    Back to Top Button with HTML, CSS and JavaScript: • Back to Top Button wit...
    Keeping Footer at the Bottom of the Page (HTML & CSS): • Keeping Footer at the ...
    Currency Converter with HTML, CSS and JavaScript: • Currency Converter wit...
    Thanks for watching! For any questions, suggestions or just to say hi, please use the comment section below!
    Codepen: codepen.io/Cod...
    Twitter: / codingjrney
    Email: codingjourney123@gmail.com
    Subscribe 💖
    / @codingjourney

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

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

    Thank you, this is my favorite 3D Flip effect video because you actually show us how to do it with a click instead of just hover

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

      Oh thank you for the lovely comment!! Very glad you found this useful 🙂💙

  • @user-mu5jw9wn6d
    @user-mu5jw9wn6d 2 ปีที่แล้ว +3

    omg Thank you Your explanation was so good that I could easily understand even though I was Korean. It's amazing. many thanks

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

      Amazing thank you! Keep it up 💙💙

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

    Dude I donno how to thank you. Caz I was trying to understand one concept which u said at the video. To be honest I'm not gonna say what is it but not even a single person or website said why that bunch of was there. Everyone passed that and explained except you. Still appreciate and thanks man 🤞🔥

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

      Thanks for the lovely message mate!! My pleasure 🙂 All the best, keep coding 😉💙

  • @user-hn8kl6su7o
    @user-hn8kl6su7o ปีที่แล้ว +1

    Thank you so much for the tutorial. I've spent two days writing pretty long js script, but you did it in 20mins and code is so short and elegant. Amazing

  • @sumitjha392
    @sumitjha392 3 ปีที่แล้ว +5

    The fact that you add each CSS property by explaining them first makes your tutorial super super awesome. Thanks mate :) Liked and Subscribed :)

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

      Oh thanks for the lovely comment mate! 🙏🙂 Very glad you liked it!! Welcome aboard 💙💙

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

    Sir, I'm from india....thank you so much for explaining this concept...I have seen soo many videos on videos on this topic but none of them explained

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

      Oh thank you 🙂 Very glad you found this useful!! 💙

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

    I watched many tutorials about css, but this is the best tutorial thanx dude. Anyone can teach but the important thing is the audience or student need to understand. From that end you are best. Thanx

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

      Oh thank you for the lovey comment!! 🙂 My pleasure, very glad you liked this! Keep coding 😉💙

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

      @@CodingJourney noted with many thanx. Waiting for more

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

    Thank you - I've been searching for a flip card effect that didn't involve absolute positioning on the container - so helpful!

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

      Amazing! Glad it was helpful 🙂 You can always of course absolutely position the card, but that's a special case, I usually prefer presenting the general/default. All the best, keep coding 😉

  • @kristian4803
    @kristian4803 3 ปีที่แล้ว +5

    Great tutorial. You do a very good job of explaining why you do the things you do and how it works.

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

      Thank you, I appreciate that! Very glad you liked it 🙂

  • @ben-cb5er
    @ben-cb5er 3 ปีที่แล้ว +2

    Liked and subscribed! Thank you

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

      Awesome, thank you!! Welcome aboard 😉

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

    This is one of the best tutorials I've watched on HTML and CSS. Your tutorial was clear, concise, and informative! Liked and subscribed!

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

      Thanks mate! Welcome aboard 🙂💙

  • @user-vu7ew6qm4c
    @user-vu7ew6qm4c 3 ปีที่แล้ว +2

    Thanks!!! great video.
    I like your channel

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

      Oh thank you, my pleasure 🙂 Thanks for the nice comments and support!! 💙

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

    Great Sir Loved It

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

    Thank you so much for this. I'm going to use it to make online flash cards for my students. This must take you such a long time to put together, thank you!

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

      My pleasure 🙂 Yeap, it does take time (I'm sure that you, as a teacher totally get it 😉) but it's worth it! Especially when these projects are being used for such a good cause 🙂 All the best!!

  • @MB-gf6zd
    @MB-gf6zd 5 ปีที่แล้ว +2

    Awesome and super well explained !!!
    Many thanks

    • @CodingJourney
      @CodingJourney  5 ปีที่แล้ว

      Thanks man! Glad you liked it 🙂

  • @doorbell1982
    @doorbell1982 5 ปีที่แล้ว +3

    WONDERFUL tutorial, and very useful, thanks!!

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

    Great tutorial and very nice demo. Well explained.

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

      Thank you 🙂 Very glad you liked it!!

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

    Very good.

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

      Oh thank you, glad you liked it!!

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

    thanks a lot, i am clear the rotate flip card design now...

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

      Amazing! Very glad it helped 🙂

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

    I relate how you assign CSS class names xD

  • @kupaporusku
    @kupaporusku 5 ปีที่แล้ว +3

    I like the way how You teach.

    • @CodingJourney
      @CodingJourney  5 ปีที่แล้ว +1

      Thank man! I'm trying...sometimes I'm happy with the result, sometimes not...that's life 🙂 All the best, keep it up!!

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

    awesome

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

    Excellent tutorial. Thanks! God bless you :)

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

      Thanks man! U2 💙🙂 Very glad you liked it!

  • @LIFE-nr1yg
    @LIFE-nr1yg 4 ปีที่แล้ว +2

    simple and elegant, thank you

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

      Thank you! 😊 Very glad you liked it!!

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

    awesome video great explanation!!

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

      Thank youuuu 🙂 Very glad you liked it!!

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

    powerfull

  • @_STF2023_the_camera.kinemaster
    @_STF2023_the_camera.kinemaster 4 ปีที่แล้ว +1

    Good job man. Thanks for it. Silas from Brazil.

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

      Hey Silas my man! Amazing, very glad you liked it 🙂 Warm greetings to Brazil!!

  • @jimboli9400
    @jimboli9400 5 ปีที่แล้ว +1

    This is great thanks, it really helped with school work

    • @CodingJourney
      @CodingJourney  5 ปีที่แล้ว

      That's awesome! All the best with school, keep progressing!!

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

    Very nice

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

      Thanks!! Very glad you liked it 🙂

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

    ❤❤❤

  • @Tony-pe3kp
    @Tony-pe3kp 5 ปีที่แล้ว +1

    Excellent thanks!!

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

    Thanks man!

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

    Love the tuturial. Is there a way to flip from the center of the card without defining the pixels in the card-container.

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

    Super tutorials, best work thank you somuch

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

      Thank you for this lovely comment man! Very happy to hear that 🙂

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

    nice ... because good working ...

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

      Thanks man, glad you liked it!!

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

    Great video bro. Only one question: when I try to create multiple flip-cards, only one card will respond to my clicking, the rest don't respond. How can I adjust my JS to apply the toggling to all elements in a class?

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

      Thanks man! In this case you would want to select all cards (so use querySelectorAll instead of querySelector), loop through selected cards (e.g. with a for-loop or a forEach method) and add the "click" event listener to each card. A working code snippet for this purpose would be the following:
      const flipCardContainers = document.querySelectorAll(".flip-card-container");
      flipCardContainers.forEach(function(flipCardContainer) {
      flipCardContainer.addEventListener("click", function() {
      flipCardContainer.classList.toggle("flip");
      });
      });
      All the best!!

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

      @@CodingJourney Thank you so much :D

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

    Lovely brother....

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

      Thanks bro! Glad you liked it!!

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

    Excellent work my friend! I very much enjoyed your tutorial! I'm wondering though why my images are not smooth transitioning on click but they kind of 'bounce' or "jiggle" a little on transition? I'm using SVG illustrations with all objects grouped together. Any advice would be greatly appreciated and thank you so much!

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

      I notice this was only happening in Firefox browser! Works perfectly in Brave and Chrome! Any ideas would be greatly appreciated. Thank you

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

    great video! Any way to make it flip when clicked without using javascript? using only html, css and php?

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

    I don't know if you still respond to this video or not, but I was wondering if there is a way to have the flip stay in one direction (i.e., image flips to the left, and then it flips to the left again, flips forward, and then it flips forward again, etc.)? This is kind of hard for me to explain this, so I hope you at least somewhat understand what I mean.

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

    Such a good video. However, having difficulty getting the JS to work do you have a source code for that please?

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

      I worked it out I still had :flip rather than .flip

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

      Thank you 🙂 You can find a link in the description! However, I don't think I've included the JS part...so for that you will have to follow the video instructions...that shouldn't be more than a couple of minutes starting from 18:00 🙂 There was also a question in the comments about adding the "click" event listener to multiple cards so you might also want to check that answer! Good luck!! 🙂

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

    I'm trying to do multiple cards on the same page but can only get the click to work for the first card. Any idea on how to do the querySelector for multiple cards?

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

      Hello! I'm pasting my reply to a similar question so that you don't have to go through the comments:
      In this case you would want to select all cards (so use querySelectorAll instead of querySelector), loop through selected cards (e.g. with a for-loop or a forEach method) and add the "click" event listener to each card. A working code snippet for this purpose would be the following:
      const flipCardContainers = document.querySelectorAll(".flip-card-container");
      flipCardContainers.forEach(function(flipCardContainer) {
      flipCardContainer.addEventListener("click", function() {
      flipCardContainer.classList.toggle("flip");
      });
      });
      Hope this helps! All the best, keep coding 😉💙

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

      @@CodingJourney Thank you so much! Amazing tutorial!

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

    how to put many cards horizontally

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

    Anyone knows if this working on safari and ios safari?? I've done one and checked can i use and it seems safari is not supported??

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

      Hello! Check out the comment by MsRobynM and the solution we came up with. Hopefully that solves the problem...All the best!! 😉

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

    Great video but does not seem to work on Safari. On hover just get a reversed pic. Anyone know why or how it's fixed?

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

      Hello 🙂 Thanks and sorry for the late reply! Unfortunately I currently don't have access to Safari browser so that I can debug but maybe this is due to the backface-visibility property...I think Safari still requires a prefix. So maybe the following would do the job:
      -webkit-backface-visibility: hidden; /* Safari */
      backface-visibility: hidden;
      All the best, keep coding 😉🙂

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

      @@CodingJourney That's exactly what it was. It all works perfectly now on Safari. Thanks.

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

      Amazing! Thanks for pointing this out 🙂

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

    como faz para colocar um cartão ao lado do outro?

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

    For some reason when my card flips - it remains visible? I can now see the back of the card around the image that is on the front. Any thoughts?

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

      Hey mate! There's a (CodePen) link to this project in the description. If that works fine for you, then you can compare the code and hopefully make it work as intended!! All the best 💙

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

      @@CodingJourney Nope. Same result unfortunately. I'm giving up for now. I did save, though. Thanks! Not sure what I'm doing wrong.

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

      Did you set "transform-style: preserve-3d;" for the ".flip-card"? But it could be anything, it is impossible to debug without looking at the code...I'm quite sure that if you really want to make it work, you eventually will 🙂 Keep coding 😉💙

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

    is this responsive? if not how do i make it responsive?

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

      Hello 🙂 In order to concentrate on the main goal of this tutorial, which was the card flip effect implementation, I used for example fixed width and height for the card. You can always use media queries in order to control the layout for different screen sizes. For example, in order to reduce the card size for smaller screens you could do the following in CSS:
      @media(max-width:767px) {
      .flip-card-container {
      width: 240px;
      height: 320px;
      }
      }
      All the best!! 🙂

  • @CyrusCole
    @CyrusCole 5 ปีที่แล้ว

    I'm having a bit of an issue. Everytime my mouse hovers close to the edge of the card, it kind of flickers back and forth and doesnt always rotate. Please help me

    • @CodingJourney
      @CodingJourney  5 ปีที่แล้ว

      Hey!! There shouldn't be a flickering issue while hovering close to edges, since flipping occurs when hovering over the flip-card-container element, which itself doesn't move. I think if you follow the tutorial carefully you should be fine or, if you don't have time for this, you can find the final code for this project in the description link. Keep it up!!!

    • @CyrusCole
      @CyrusCole 5 ปีที่แล้ว +1

      @@CodingJourney Thank you for the help. I realised I made a mistake and decided to stop with this idea. I'm trying to make a coffee website for my school project. And I was trying to incorporate this tutorial with the cards that I put into a display: grid. But I made a mistake because the cards were doing that jitter thing. So I dumped it and put all the info onto the card without any effects

    • @CodingJourney
      @CodingJourney  5 ปีที่แล้ว

      Very nice! Adjustability, that's the spirit 🙂 All the best with school project!!!

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

    hello! can this move side to side instead of flipping front and back?

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

      Hey 🙂 In general, anything you imagine, you can do 😉 This video is about the card flip effect though! I've also created a video about the slide-in overlay effect, feel free to check it out, maybe it is closer to what you are looking for! All the best, keep coding 🙂💙

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

      @@CodingJourney Thank You for your reply! I am actually looking at this: th-cam.com/video/pZZAVRHKsvg/w-d-xo.html , will your tutorial be able to do that?

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

      No, that's an entirely different component! You can ask that specific creator for guidance! Good luck 💙

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

    You write ( div.flip-card ) then it's to be ()
    what is a shortcut?

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

      Hey! 🙂 You can do this due to the Emmet plug-in (if you are using Visual Studio Code then it's already there, otherwise you may have to install it).
      So by typing:
      div.flip-card + enter/return (or tab)
      You get:
      For the special case of "div" you can simply type:
      .flip-card + enter/return (or tab)
      And you still get:
      I hope this answers your question! All the best, keep coding 😉

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

      @@CodingJourney i used Adobe Dreamwewer, How could i do?

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

      Unfortunately I've never used the Adobe Dreamwewer editor so I can't give you specific instructions on how to enable Emmet. I'm sure you will eventually figure it out, good luck!

  • @juliuso1
    @juliuso1 5 ปีที่แล้ว

    The flip effect is buggy on Safari and iOS devices. But otherwise a good tutorial.

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

      Safari is the new IE

  • @anhduc1123
    @anhduc1123 5 ปีที่แล้ว

    How to make it click to flip ?

    • @CodingJourney
      @CodingJourney  5 ปีที่แล้ว +1

      Hey man! I think explanation for what you are asking for, starts at 18:00. Good luck!!