<div class="credit-card" style="--y: 0deg; --x: 0deg;">
<div class="credit-card-top">
<div class="credit-card-title">lorem bank</div>
<img class="credit-card-logo" src="https://i.imgur.com/i8L9D5l.png" alt="Mastercard" />
</div>
<div class="credit-card-bottom">
<div>
<div class="credit-card-number">5782 8181 6161 0000</div>
<div class="credit-card-holder">John Doe</div>
</div>
<img class="credit-card-nfc" src="https://i.imgur.com/9xbDn7v.png" alt="NFC">
</div>
</div>
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Inconsolata:wght@500&display=swap');
*,
*::before,
*::after {
box-sizing: border-box;
}
html,
body {
margin: 0;
padding: 0;
}
body {
min-height: 100vh;
display: grid;
place-items: center;
background-color: #861657;
background-image: linear-gradient(326deg, #861657 0%, #ffa69e 74%);
font-family: 'Poppins', sans-serif;
perspective: 1000px;
}
.credit-card {
width: 4.044in;
height: 2.55in;
border-radius: 0.15in;
background: rgba(255, 255, 255, 0.25);
box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
backdrop-filter: blur( 4px );
-webkit-backdrop-filter: blur(4px);
border-radius: 10px;
border: 1px solid rgba(255, 255, 255, 0.18);
padding: 20px;
color: #070600;
display: flex;
flex-direction: column;
justify-content: space-between;
cursor: default;
transform-style: preserve-3d;
&-top {
display: flex;
justify-content: space-between;
}
&-bottom {
display: flex;
align-items: center;
justify-content: space-between;
}
&-title {
font-size: 1.5rem;
font-weight: 600;
}
&-logo {
width: 50px;
height: auto;
}
&-number {
font-size: 1.2rem;
font-weight: 500;
}
&-number {
font-family: 'Inconsolata', monospace;
font-size: 1.5rem;
font-weight: 500;
margin-bottom: 10px;
}
&-nfc {
width: 40px;
height: auto;
}
}
View Compiled
const creditCard = document.querySelector(".credit-card");
document.body.addEventListener("mousemove", (e) => {
const cx = e.clientX,
cy = e.clientY;
let rx, ry;
rx = ((cx / window.innerWidth) * 20) - 10;
ry = ((cy / window.innerHeight) * 20) - 10;
creditCard.style.transform = `rotateY(${rx}deg) rotateX(${ry}deg)`;
});
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.