卡片翻转动画Internet Explorer 11

Wal*_*ari 11 html javascript css jquery internet-explorer

我试图让卡片翻转并显示其背面.它适用于所有其他浏览器,但不适用于Internet Explorer 11.

我已经尝试添加-ms-前言,但这没有帮助.问题似乎是IE不支持css属性transform-style: preserve-3d.

这是一个jsfiddle:https://jsfiddle.net/gbkq94hr/

HTML

<body>
    <article>
        <div id="card0" class="card">
            <figure class="front">
            </figure>
            <figure class="back">
            </figure>
        </div>
    </article>
</body>
Run Code Online (Sandbox Code Playgroud)

JS

$(document).ready(function () {
    var flipped = false;
    var card = $("#card0");
    card.click(function() { flipFunction();});

    function flipFunction() {
        if (flipped) {
            flipped = false;
            card.removeClass('flip');
        } else {
            card.addClass('flip');
            flipped = true;
        }
    };
});
Run Code Online (Sandbox Code Playgroud)

CSS

html {
    height: 100%;
}

.flip {
    transform: rotateY(180deg);
}

.card {
    float:left;
    width: 110px;
    height: 139px;
    cursor: pointer;
    transform-style: preserve-3d;
    transition: transform 1s;
    position: relative;
}

figure {
    margin: 0;
    display: block;
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -ms-backface-visibility:hidden;
}

.back {
    background-color: blue;
    transform: rotateY(-180deg);
}

.front {
    z-index: 2;
    background-color: red;
    transform:rotateY(0deg);
}

article {
    height: 114px;
    width: 114px;
    perspective: 1000;
}
Run Code Online (Sandbox Code Playgroud)

编辑:

正如评论中所建议的那样,我尝试遵循David Walshes的说明,但仍无法使其发挥作用.https://jsfiddle.net/w9o2chmn/2/

RRR*_*RRR 4

您好,我更改了 jQuery 代码以在单击时执行卡片翻转。请检查https://jsfiddle.net/w9o2chmn/6/

HTMLflip-container向文章标签添加了类

<article class="flip-container">
    <div id="card0" class="card">
        <figure class="front">
        front
        </figure>
        <figure class="back">
        back
        </figure>
    </div>
</article>
Run Code Online (Sandbox Code Playgroud)

CSS 我已经删除了 CSS:hover代码并将其放在 jQuery click 中

/* entire container, keeps perspective */
.flip-container {
    perspective: 1000;
    transform-style: preserve-3d;
  color:#fff;
}

/*  UPDATED! flip the pane when hovered */
    /*.flip-container:hover .back {
        transform: rotateY(0deg);
    }
    .flip-container:hover .front {
        transform: rotateY(180deg);
    }*/

.flip-container, .front, .back {
    width: 200px;
    height: 200px;
}

/* flip speed goes here */
.card {
    transition: 0.6s;
    transform-style: preserve-3d;

    position: relative;
}

/* hide back of pane during swap */
.front, .back {
    backface-visibility: hidden;
    transition: 0.6s;
    transform-style: preserve-3d;

    position: absolute;
    top: 0;
    left: 0;
}

/*  UPDATED! front pane, placed above back */
.front {
    z-index: 2;
    transform: rotateY(0deg);
  background:red;
}

/* back, initially hidden pane */
.back {
    transform: rotateY(-180deg);
  background:blue;
}

/* 
Run Code Online (Sandbox Code Playgroud)

jQuery

$(document).ready(function() {
    var flipped=false;

    $('.flip-container').on('click', function(){
        if(!flipped){
      $('.back').css('transform','rotateY(0deg)');
      $('.front').css('transform','rotateY(180deg)');
      flipped=true;
      console.log('true part :'+flipped);
      }
      else{
        $('.back').css('transform','rotateY(180deg)');
      $('.front').css('transform','rotateY(0deg)');
      flipped=false;
      console.log('else part :'+flipped);
      }
    });


});
Run Code Online (Sandbox Code Playgroud)

请告诉我它是否适合您......

PS:我在 IE11 上测试了它,它对我有用

  • jsFiddle 在 IE11 中不适用于我。我使用的是 Windows 10 (3认同)