A Pen by Bakaki Mahlon on CodePen.
Last active
December 3, 2021 13:43
-
-
Save Git2020104/71103833d340dbe612126b8cdf84200f to your computer and use it in GitHub Desktop.
3D CSS card
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<d<iv class="card-container"> | |
<div class="card"> | |
<h3>Hover me</h3><br> | |
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Quod maiores sapiente non asperiores deleniti, quos eos placeat corrupti id consequatur ullam accusantium, nesciunt aut fugiat at ipsam harum eveniet dolore.</p> | |
<div class="layers"> | |
<div class="layer"></div> | |
<div class="layer"></div> | |
<div class="layer"></div> | |
<div class="layer"></div> | |
<div class="layer"></div> | |
<div class="layer"></div> | |
<div class="layer"></div> | |
<div class="layer"></div> | |
<div class="layer"></div> | |
<div class="layer"></div> | |
</div> | |
</div> | |
</d> | |
<div class="card-container"> | |
<div class="card"> | |
<h3>Hover me</h3><br> | |
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Quod maiores sapiente non asperiores deleniti, quos eos placeat corrupti id consequatur ullam accusantium, nesciunt aut fugiat at ipsam harum eveniet dolore.</p> | |
<div class="layers"> | |
<div class="layer"></div> | |
<div class="layer"></div> | |
<div class="layer"></div> | |
<div class="layer"></div> | |
<div class="layer"></div> | |
<div class="layer"></div> | |
<div class="layer"></div> | |
<div class="layer"></div> | |
<div class="layer"></div> | |
<div class="layer"></div> | |
</div> | |
</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://assets.codepen.io/1948355/twitterButton-2.1.0.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@import url("https://fonts.googleapis.com/css?family=Raleway:400,400i,700"); | |
* { | |
margin: 0 auto; | |
padding: 0; | |
box-sizing: border-box; | |
} | |
body { | |
font-family: Raleway, sans-serif; | |
display: flex; | |
align-items: center; | |
min-height: 100vh; | |
background-color: #ddd; | |
} | |
.card-container { | |
perspective: 50em; | |
&:nth-child(1) { --bi: repeating-linear-gradient(30deg, #111 0 0.25em, #333 0 1em); } | |
&:nth-child(2) { --bi: linear-gradient(#555 5em, #0000 3em), linear-gradient(60deg, #880E4F, #1A237E); } | |
} | |
.card { | |
position: relative; | |
width: 320px; | |
padding: 3em; | |
color: #fff; | |
transform: rotateY(30deg) rotateX(15deg); | |
transform-style: preserve-3d; | |
transition: transform 1s; | |
&:hover { | |
transform: rotateY(-30deg) rotateX(-15deg); | |
} | |
} | |
.layers { | |
position: absolute; | |
left: 0; top: 0; | |
width: 100%; height: 100%; | |
transform-style: preserve-3d; | |
z-index: -1; | |
} | |
.layer { | |
position: absolute; | |
left: 0; top: 0; | |
width: 100%; height: 100%; | |
border-radius: 1em; | |
background-image: var(--bi); | |
transform: translateZ(var(--tz)); | |
box-shadow: 0 0 0.5em #000d inset; | |
@for $i from 0 to 10 { | |
&:nth-child(#{$i + 1}) { | |
--tz: #{$i * -4}px; | |
} | |
} | |
&:last-child { | |
box-shadow: 0 0 0.5em #000d inset, 0 0 5px #000; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment