Using 3D transform flip is not working in IE11 (mi

2019-02-28 15:57发布

问题:

I investigate on CSS3 3d transform and finally I got some code for CSS3 3d flip action. So it's working fine in all browsers except Internet Explorer (IE11). So I investigated on this issue in stackoverflow.com. I got some solutions but unfortunately those are not useful for me. So please kindly have a look at my jsfiddle link and provide some solution for this.

CODE:

$('#one').click(function() {
        if ($(this).is(':checked')) {
          $("#card").addClass("flipped");
            $(".back #append").append("<p>First one</p>")
        }
    });
$('#two').click(function() {
        if ($(this).is(':checked')) {
          $("#card").addClass("flipped");
            $(".back #append").append("<p>second one</p>")
        }
    });
$('#three').click(function() {
        if ($(this).is(':checked')) {
          $("#card").addClass("flipped");
            $(".back #append").append("<p>third one</p>")
        }
    });
$('#close').click(function() {
    $("#card").removeClass("flipped");
});
.container { 
  width: 200px;
  height: 260px;
  position: relative;
  -ms-perspective: 800px;
  perspective: 800px;
}
#card {
  width: 100%;
  height: 100%;
  position: absolute;
  -ms-transform-style: preserve-3d;
  transform-style: preserve-3d;
  transition: transform 1s;
}
#card figure {
  display: block;
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  margin:0px;
  padding:0px;  
}
#card .front {
  background: red;
}
#card .back {
  background: blue;
    -ms-transform: rotateY( 180deg );
  transform: rotateY( 180deg );
}
#card.flipped {
  -ms-transform: rotateY( 180deg );
  transform: rotateY( 180deg );
}
#close{
    position:absolute;bottom:0px;right:0px;color:#fff;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<section class="container">
  <div id="card">
    <figure class="front">
        <input type="checkbox" id="one"/>one<br></br>
        <input type="checkbox" id="two"/>two<br></br>
        <input type="checkbox" id="three"/>three<br></br>
      </figure>
    <figure class="back">
        <div id="append"></div>
        <div id="close"><button>close</button></div>
    </figure>
  </div>
</section>

for more details see this link: http://jsfiddle.net/Rayudu/jy0z8dy1/

kindly click on check box then flip will happen and click on close button to remove flip.

回答1:

I had run into the same problem earlier and found that making the back-face visible in the flipped state solves it. So for your case, adding the below lines should fix the issue in IE11 (and also IE10).

#card.flipped figure{
  backface-visibility: visible;
}

$('#one').click(function() {
  if ($(this).is(':checked')) {
    $("#card").addClass("flipped");
    $(".back #append").append("<p>First one</p>")
  }
});
$('#two').click(function() {
  if ($(this).is(':checked')) {
    $("#card").addClass("flipped");
    $(".back #append").append("<p>second one</p>")
  }
});
$('#three').click(function() {
  if ($(this).is(':checked')) {
    $("#card").addClass("flipped");
    $(".back #append").append("<p>third one</p>")
  }
});
$('#close').click(function() {
  $("#card").removeClass("flipped");
});
.container {
  width: 200px;
  height: 260px;
  position: relative;
  -ms-perspective: 800px;
  perspective: 800px;
}
#card {
  width: 100%;
  height: 100%;
  position: absolute;
  -ms-transform-style: preserve-3d;
  transform-style: preserve-3d;
  transition: transform 1s;
}
#card figure {
  display: block;
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  margin: 0px;
  padding: 0px;
}
#card .front {
  background: red;
}
#card .back {
  background: blue;
  -ms-transform: rotateY(180deg);
  transform: rotateY(180deg);
}
#card.flipped {
  -ms-transform: rotateY(180deg);
  transform: rotateY(180deg);
}
#card.flipped figure {
  backface-visibility: visible;
}
#close {
  position: absolute;
  bottom: 0px;
  right: 0px;
  color: #fff;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<section class="container">
  <div id="card">
    <figure class="front">
      <input type="checkbox" id="one" />one
      <br></br>
      <input type="checkbox" id="two" />two
      <br></br>
      <input type="checkbox" id="three" />three
      <br></br>
    </figure>
    <figure class="back">
      <div id="append"></div>
      <div id="close">
        <button>close</button>
      </div>
    </figure>
  </div>
</section>


Note: Addition of the above property setting seems to be causing some flickers in Google Chrome and that could be overcome by over-riding the setting for GC alone (like in this fiddle kindly contributed by web-tiki). Generally it is not a good approach to add prefixed versions after the un-prefixed (standard) property, but it is not much of an issue here as we are over-riding specifically for Chrome.