翻转后的图像是镜像的,如何使翻转后的图像不镜像?

Flipped image is mirrored, how do make the flipped image not mirrored?

我尝试了各种方法将图像 1 翻转为图像 2,最后决定不使用任何 jquery 插件,就这样做了。使用 javascript 将图像 2 插入到 "back1" 图像 class 中。但是现在翻转后的图像2是原始图像2的镜像。如何使翻转后的图像不是镜像?

提前致谢。

wala = document.getElementsByClassName("back1"); 
wala[0].src = "https://placehold.it/300x200"; 
wala[0].style.cssFloat = "inherit";


function flip() {
    $('.cardx').toggleClass('flipped');
}
.containerx {
    width: 300px;
    height: 200px;
    position: relative;
    border: 2px solid grey;
}
.cardx {
    width: 100%;
    height: 100%;
    position: absolute;
    -webkit-transition: -webkit-transform 2s;
    -moz-transition: -moz-transform 2s;
    -o-transition: -o-transform 2s;
    transition: transform 2s;
    -webkit-transform-style: preserve-3d;
    -moz-transform-style: preserve-3d;
    -o-transform-style: preserve-3d;
    transform-style: preserve-3d;

}
.cardx div {
    display: block;
    height: 100%;
    width: 100%;
    position: absolute;
    -webkit-backface-visibility: hidden;
    -moz-backface-visibility: hidden;
    -o-backface-visibility: hidden;
    backface-visibility: hidden;

}
.cardx .front {
  background: url("https://placehold.it/300x200/DCF8FF/333333")
}
.cardx .back {
    -webkit-transform: rotateY( 180deg );
    -moz-transform: rotateY( 180deg );
    -o-transform: rotateY( 180deg );
    transform: rotateY( 180deg );

}
.cardx.flipped {
    -webkit-transform: rotateY( 180deg );
    -moz-transform: rotateY( 180deg );
    -o-transform: rotateY( 180deg );
    transform: rotateY( 180deg );

}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<section class="containerx">
  <div class="cardx" onclick="flip()">
    <div class="front"></div>

    <div class="back"></div>
        <img class= "back1" alt="logo back" /> 
  </div>
</section>

将 scaleX(-1) 添加到背面元素上的 css 变换以转义翻转图像。

.cardx .back {
    -webkit-transform: rotateY( 180deg ) scaleX(-1);
    -moz-transform: rotateY( 180deg ) scaleX(-1);
    -o-transform: rotateY( 180deg ) scaleX(-1);
    transform: rotateY( 180deg ) scaleX(-1);

}

.cardx.flipped {
    -webkit-transform: rotateY( 180deg ) scaleX(-1);
    -moz-transform: rotateY( 180deg ) scaleX(-1);
    -o-transform: rotateY( 180deg ) scaleX(-1);
    transform: rotateY( 180deg ) scaleX(-1);

}

查看更新的代码段:

wala = document.getElementsByClassName("back1"); 
wala[0].src = "https://placehold.it/300x200"; 
wala[0].style.cssFloat = "inherit";


function flip() {
    $('.cardx').toggleClass('flipped');
}
.containerx {
    width: 300px;
    height: 200px;
    position: relative;
    border: 2px solid grey;
}
.cardx {
    width: 100%;
    height: 100%;
    position: absolute;
    -webkit-transition: -webkit-transform 2s;
    -moz-transition: -moz-transform 2s;
    -o-transition: -o-transform 2s;
    transition: transform 2s;
    -webkit-transform-style: preserve-3d;
    -moz-transform-style: preserve-3d;
    -o-transform-style: preserve-3d;
    transform-style: preserve-3d;

}
.cardx div {
    display: block;
    height: 100%;
    width: 100%;
    position: absolute;
    -webkit-backface-visibility: hidden;
    -moz-backface-visibility: hidden;
    -o-backface-visibility: hidden;
    backface-visibility: hidden;

}
.cardx .front {
  background: url("https://placehold.it/300x200/DCF8FF/333333")
}
.cardx .back {
    -webkit-transform: rotateY( 180deg ) scaleX(-1);
    -moz-transform: rotateY( 180deg ) scaleX(-1);
    -o-transform: rotateY( 180deg ) scaleX(-1);
    transform: rotateY( 180deg ) scaleX(-1);

}
.cardx.flipped {
    -webkit-transform: rotateY( 180deg ) scaleX(-1);
    -moz-transform: rotateY( 180deg ) scaleX(-1);
    -o-transform: rotateY( 180deg ) scaleX(-1);
    transform: rotateY( 180deg ) scaleX(-1);

}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<section class="containerx">
  <div class="cardx" onclick="flip()">
    <div class="front"></div>

    <div class="back"></div>
        <img class= "back1" alt="logo back" /> 
  </div>
</section>