While studying a little bit of HTML, I came across something iI'm unable to understand.
When i'm laying 2 divs on top of each other, I noticed that if the second div is turned 180deg (i.e transform:rotateY(180deg)
), the first is shown and vice versa (at least on chrome). Could someone please explain to me how it works or what are the rules? Does it have anything to do with z-indexing?
Here is a code that illustrates my question: https://jsfiddle.net/psgqktcn/3/
.card {
height: 80px;
width: 50px;
line-height: 80px;
font-size: 60px;
position: absolute;
text-align: center;
transform-style: preserve-3d;
}
.card .front1 {
background: red;
}
.card .back1 {
background: green;
}
.card .front2 {
background: red;
transform: rotateY(180deg);
}
.card .back2 {
background: green;
transform: rotateY(180deg);
}
.card figure {
position: absolute;
height: 100%;
width: 100%;
color: white;
}
<div class=card class=flipped>
<figure class="front1">1</figure>
<figure class="back1">2</figure>
</div>
<div class=card class=flipped style="margin: 0 100px">
<figure class="front2">1</figure>
<figure class="back1">2</figure>
</div>
<div class=card class=flipped style="margin: 0 200px">
<figure class="front1">1</figure>
<figure class="back2">2</figure>
</div>