Flip a 3D Map Using CSS

I am trying to make a 3D map effect with CSS as follows.

3D map with CSS

The difference is that I want to use only CSS to implement it.

Here is the code I tried:

/*** LESS: ***/

    .card-container {
        position: relative;
        height: 12rem;
        width: 9rem;
        perspective: 30rem;
        .card {
            position: absolute;
            width: 100%;
            height: 100%;            
            div {
                position: absolute;
                height: 100%;
                width: 100%;
            }
            .front {
                background-color: #66ccff;
            }
            .back {
                background-color: #dd8800;
                backface-visibility: hidden;
                transition: transform 1s;
                &:hover {
                    transform: rotateY(180deg);
                }
            }
        }
    }
HTML:
<div class="card-container">
  <div class="card">
    <div class="front"><span>Front</span></div>
    <div class="back"><span>Back</span></div>
  </div>
</div>
Run codeHide result

The problem is that the card does not flip; it latches back forward:

The discarding card effect does not work

Is it possible to implement this 3D map effect with hovering using only CSS?

+4
source share
1 answer

, , -. Y , :

3D hover overturn map

, filp:  - Y  - , .back div. , div "" . , .  - ,

CSS- - :

.card {
  position: relative;
  width: 9rem; height: 12rem;
  perspective: 30rem;
}
.front, .back {
  position: absolute;
  width: 100%; height: 100%;
  transition: transform 1s;
  backface-visibility:hidden;
}
.front { 
  background-color: #66ccff; 
}
.back { 
  background-color: #dd8800; 
  transform: rotateY(180deg); 
}
.card:hover .front{ transform: rotateY(180deg); }
.card:hover .back { transform: rotateY(360deg); }
<div class="card">
  <div class="front"><span>Front</span></div>
  <div class="back"><span>Back</span></div>
</div>
Hide result

, , . . CanIuse 3d- transitions.

+8

Source: https://habr.com/ru/post/1665704/


All Articles