使用 3D 变换翻转在 IE11 中不起作用(我的不同)
Using 3D transform flip is not working in IE11 (mine is different)
我调查了 CSS3 3d 变换,最后我得到了一些 CSS3 3d 翻转动作的代码。所以它在除 Internet Explorer (IE11) 之外的所有浏览器中都运行良好。
所以我在 whosebug.com 中调查了这个问题。我得到了一些解决方案,但不幸的是这些对我没有用。所以请看看我的 jsfiddle link 并为此提供一些解决方案。
代码:
$('#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>
有关详细信息,请参阅此 link:http://jsfiddle.net/Rayudu/jy0z8dy1/
请点击复选框然后翻转将发生,点击关闭按钮取消翻转。
我之前 运行 遇到过同样的问题,发现在翻转状态下使背面可见可以解决问题。因此,对于您的情况,添加以下行应该可以解决 IE11(以及 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>
注意: 添加上述 属性 设置似乎会导致 Google Chrome 出现一些闪烁,这可以通过以下方式克服单独覆盖 GC 的设置(如 this fiddle kindly contributed by web-tiki)。通常,在无前缀(标准)属性 之后添加前缀版本并不是一个好方法,但这并不是什么大问题,因为我们专门针对 Chrome.
我调查了 CSS3 3d 变换,最后我得到了一些 CSS3 3d 翻转动作的代码。所以它在除 Internet Explorer (IE11) 之外的所有浏览器中都运行良好。 所以我在 whosebug.com 中调查了这个问题。我得到了一些解决方案,但不幸的是这些对我没有用。所以请看看我的 jsfiddle link 并为此提供一些解决方案。
代码:
$('#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>
有关详细信息,请参阅此 link:http://jsfiddle.net/Rayudu/jy0z8dy1/
请点击复选框然后翻转将发生,点击关闭按钮取消翻转。
我之前 运行 遇到过同样的问题,发现在翻转状态下使背面可见可以解决问题。因此,对于您的情况,添加以下行应该可以解决 IE11(以及 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>
注意: 添加上述 属性 设置似乎会导致 Google Chrome 出现一些闪烁,这可以通过以下方式克服单独覆盖 GC 的设置(如 this fiddle kindly contributed by web-tiki)。通常,在无前缀(标准)属性 之后添加前缀版本并不是一个好方法,但这并不是什么大问题,因为我们专门针对 Chrome.