Bootstrap flip card with css3 transform

本秂侑毒 提交于 2019-12-19 03:14:22

问题


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.


回答1:


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

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

});

demo



来源:https://stackoverflow.com/questions/30698272/bootstrap-flip-card-with-css3-transform

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!