Skip to content

Commit

Permalink
Update rotating-card.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Chalarangelo authored Oct 4, 2020
1 parent 7c9fd63 commit 7ef1b7d
Showing 1 changed file with 48 additions and 48 deletions.
96 changes: 48 additions & 48 deletions snippets/rotating-card.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,61 +5,61 @@ tags: animation,advanced

Creates a two sided card which rotates on hover.

- Set the the `backface-visibility ` of the cards to none.
- Set the the `backface-visibility` of the cards to none.
- Initially `rotateY` the back side of the card by `-180deg` and the front side to `0deg`.
- Upon hover, `rotateY` the front side to `180deg` and backside to `0deg`.
- Set the appropriate `perspective ` value to create the rotate effect .
- Set the appropriate `perspective` value to create the rotate effect.

```html
<div class="card">
<div class="card-side front">
<div>
Front Side
</div>
</div>
<div class="card-side back">
<div>
Back Side
</div>
</div>
<div class="card-side front">
<div>Front Side</div>
</div>
<div class="card-side back">
<div>Back Side</div>
</div>
</div>
```

```css
.card {
perspective: 150rem;
-moz-perspective: 150rem;
position: relative;
height: 40rem;
max-width: 400px;
margin: 2rem;
box-shadow: none;
}
.card-side {
height: 35rem;
border-radius: 15px;
transition: all 0.8s ease;
backface-visibility: hidden;
position: absolute;
top: 0;
left: 0;
width: 80%;
padding:2rem;
color: white
}
.card-side.back {
transform: rotateY(-180deg);
background-color: #4158D0;
background-image: linear-gradient(43deg, #4158D0 0%,#C850C0 46%, #FFCC70 100%);
}
.card-side.front {
background-color: #0093E9;
background-image: linear-gradient(160deg, #0093E9 0%, #80D0C7 100%);
}
.card:hover .card-side.front {
transform: rotateY(180deg);
}
.card:hover .card-side.back {
transform: rotateY(0deg);
}
.card {
perspective: 150rem;
position: relative;
height: 40rem;
max-width: 400px;
margin: 2rem;
box-shadow: none;
}

.card-side {
height: 35rem;
border-radius: 15px;
transition: all 0.8s ease;
backface-visibility: hidden;
position: absolute;
top: 0;
left: 0;
width: 80%;
padding:2rem;
color: white
}

.card-side.back {
transform: rotateY(-180deg);
background-color: #4158D0;
background-image: linear-gradient(43deg, #4158D0 0%,#C850C0 46%, #FFCC70 100%);
}

.card-side.front {
background-color: #0093E9;
background-image: linear-gradient(160deg, #0093E9 0%, #80D0C7 100%);
}

.card:hover .card-side.front {
transform: rotateY(180deg);
}

.card:hover .card-side.back {
transform: rotateY(0deg);
}
```

0 comments on commit 7ef1b7d

Please sign in to comment.