Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap flip card with css3 transform

I want to create a bootstrap flip card by using CSS3 transform. I did started from this working and basic example

However I wanted to modify it to have a fixed height card and some minor enhancement. In particular I needed to have the card flip when the user click on an icon I have created on the top right corner.

I have modified the code as you can see here.

The problem is that the card does not flip back to front after having flipped correctly to the back side.

Can anybody suggest any solution?

NOTE: the problem seems to be with the jquery code. Actually I have

$('div.flipControl').on('click', function () {
    $(this).closest('div[class="card"]').toggleClass('flipped');
});

But if I change it with

$('div.flipControl').on('click', function () {
    $(this).parent().parent().parent().toggleClass('flipped');
});

Everything works as expected.

like image 679
Lorenzo Avatar asked Sep 27 '22 16:09

Lorenzo


1 Answers

I think that it is much simpler using directly the CSS class selector

$('.flipControl').on('click', function(){
    $(this).closest('.card').toggleClass('flipped');

});

demo

like image 188
vals Avatar answered Oct 02 '22 14:10

vals