FlipcardTutorials

CSS Flip Card jQuery Click Event

CSS Flip Card jQuery Click Event

CSS Flip Card jQuery Click Event

Before We Start

Every developer needs clean and modern elements to develop their websites, It contains pictures and a user interface element within a website. The most important one and the first section that the user sees when the user enters a website. CSS Flip Card jQuery Click Event

So if you are a person who wishes to develop a website, you have to know how to create that properly.

CSS Flip Card jQuery Click Event

We are here to solve your problem. In this article we discuss how to create these elements. Before we start please read the below articles which easier you to understand the process, if you are new to development.

Step 1 – Add HTML

It’s too easy and simple. Just copy and paste below code in your HTML editor between <body> </body> tag.

<section class="grid">
  <div class="wrap">
    <div class="card">
      <div class="front">
        <img src="https://images.pexels.com/photos/1179225/pexels-photo-1179225.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260" />
      </div>
      <div class="back">
        Back
      </div>
    </div>
  </div>
  <div class="wrap">
    <div class="card">
      <div class="front">
        <img src="https://images.pexels.com/photos/618833/pexels-photo-618833.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260" />
      </div>
      <div class="back">
        Back
      </div>
    </div>
  </div>
  <div class="wrap">
    <div class="card">
      <div class="front">
        <img src="https://images.pexels.com/photos/709552/pexels-photo-709552.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260" />
      </div>
      <div class="back">
        Back
      </div>
    </div>
  </div>
</section>

Step 2 – Add CSS

Copy and paste below code in your HTML editor between <style></style> tag.

<style>
.grid {
    display: grid;
    grid-template-columns: minmax(0,1fr) minmax(0,1fr) minmax(0,1fr);
    grid-gap: 30px;
    text-align: center;
    max-width:900px;
    margin:0 auto;
}

.wrap {
    height: 250px;
    width: 250px;
    border-radius: 100%;
    margin: 0 auto;
}
.wrap .card {
    display: block;
    width: 100%;
    height: 100%;
    transition: transform 1s;
    transform-style: preserve-3d;
    cursor: pointer;
    position: relative;
}
.wrap .card.flipped {
    transform: rotateY(180deg);
}
.wrap .card .front,
.wrap .card .back {
    position: absolute;
    width: 98%;
    height: 98%;
    line-height: 250px;
    color: darkslategrey;
    text-align: center;
    font-size: 1.3em;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    background: lightblue;
    border-radius: 100%;
    border: 3px solid dimgrey;
}
.wrap .card .front img {
  object-fit:cover;
  width:100%;
  height:100%;
  border-radius:100%;
}
.wrap .card .front:after {
    content: '->';
    position: absolute;
    bottom: -38%;
    left: 0;
    right: 0;
    font-size: 1.6em;
    color: rgba(255,255,255,.5);
    display: block;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}
.wrap .card .back {
    transform: rotateY(180deg);
    background: darkslategrey;
    color: #fff;
}
@media (max-width:767px) {
  .grid {
    display:block;
  }
  .grid .wrap {
    margin-bottom:30px;
  }
}
</style>

Step 3 – Add JavaScript

We use some external JavaScript link to this code. No need to worry about this, copy and paste below code between <head></head> tag.

<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>

And also copy and paste below JavaScript code between <script></script> tag.

<script>
// Flip card
$(".wrap .card").click(function(evt) {
  // resolves issues in some cases.
  // only allows this method to run
  // for a click event on the element
  evt.stopImmediatePropagation();
  $(this).toggleClass("flipped");
});
</script>

At the end we will have something like this. You can change fonts, colors, backgrounds and all things that you want. Enjoy it.

Your Output

CSS Flip Card jQuery Click Event

Your Output

CSS Flip Card jQuery Click Event

Video Tutorial

Please watch this video to better understand this tutorial and don’t forget to subscribe to our channel.


Help others to find out about this article on Social Media sites. If you have any doubt or any problem, don’t hesitate to contact us. Thereafter we will be able to help you and also make sure you bookmark our site on your browser.

Related Articles

Leave a Reply

Your email address will not be published.

Back to top button