js+css实现炫酷卡片翻转排列动画效果代码
代码语言:html
所属分类:其他
代码描述:js+css实现炫酷卡片翻转排列动画效果代码,包括卡片过滤、洗牌等操作。
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
body {
background: linear-gradient(135deg, #1a1a1a, #2c3e50);
background-image:
url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><rect width="100" height="100" fill="none"/><path d="M0,0 L100,0 L100,100 L0,100 Z" fill="none" stroke="rgba(255,255,255,0.05)" stroke-width="1"/><circle cx="50" cy="50" r="2" fill="rgba(255,255,255,0.1)"/></svg>'),
linear-gradient(135deg, #1a1a1a, #2c3e50);
background-size: 100px 100px, cover;
color: #fff;
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
padding: 20px;
position: relative;
overflow-x: hidden;
}
body::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background:
radial-gradient(circle at 20% 20%, rgba(139, 0, 0, 0.1) 0%, transparent 50%),
radial-gradient(circle at 80% 80%, rgba(0, 100, 0, 0.1) 0%, transparent 50%);
pointer-events: none;
z-index: 0;
}
.container {
max-width: 1200px;
text-align: center;
padding: 30px;
position: relative;
z-index: 1;
background: rgba(0, 0, 0, 0.3);
border-radius: 20px;
backdrop-filter: blur(10px);
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
border: 1px solid rgba(255, 255, 255, 0.1);
}
h1 {
font-size: 3rem;
margin-bottom: 10px;
text-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
background: linear-gradient(to right, #fff, #ccc);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
position: relative;
}
h1::after {
content: '';
position: absolute;
bottom: -10px;
left: 50%;
transform: translateX(-50%);
width: 100px;
height: 3px;
background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.5), transparent);
}
.subtitle {
color: rgba(255, 255, 255, 0.8);
margin-bottom: 40px;
font-style: italic;
text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}
.cards-container {
display: flex;
justify-content: center;
flex-wrap: wrap;
gap: 40px;
margin-bottom: 40px;
}
.card {
width: 280px;
height: 400px;
perspective: 1500px;
cursor: pointer;
margin-bottom: 30px;
position: relative;
}
/* Add card thickness with a pseudo-element */
.card::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.3);
border-radius: 15px;
transform: translateZ(-8px);
box-shadow: 0 0 15px rgba(0, 0, 0, 0.5);
z-index: -1;
}
.card::after {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.2);
border-radius: 15px;
transform: translateZ(-4px);
box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
z-index: -1;
}
.card-inner {
width: 100%;
height: 100%;
position: relative;
transform-style: preserve-3d;
transition: transform 3.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
border-radius: 15px;
}
/* Add metallic reflection effect to card faces */
.card-front::before, .card-back::before {
content: '';
position: absolute;
top: -150%;
left: -150%;
right: -150%;
bottom: -150%;
background: radial-gradient(
circle at center,
rgba(255, 255, 255, 0.3) 0%,
rgba(255, 255, 255, 0.15) 20%,
rgba(255, 255, 255, 0) 50%
);
border-radius: 50%;
z-index: 3;
pointer-events: none;
opacity: 0;
transition: opacity 0.5s ease;
}
.card:hover .card-front::before, .card:hover .card-back::before {
opacity: 0.5;
}
/* Add shine effect during flip to card faces */
.card-front::after, .card-back::after {
content: '';
position: absolute;
top: -150%;
left: -150%;
width: 400%;
height: 400%;
background: radial-gradient(
ellipse at center,
rgba(255, 255, 255, 0) 0%,
rgba(255, 255, 255, 0.2) 30%,
rgba(255, 255, 255, 0) 60%
);
transform: rotate(45deg);
z-index: 4;
pointer-events: none;
opacity: 0;
transition: opacity 0.5s ease;
}
.card:hover .card-front::after, .card:hover .card-back::after {
opacity: 0.4;
animation: shine 3.5s ease-in-out;
}
@keyframes shine {
0% {
transform: translateX(-100%) rotate(45deg);
}
100% {
transform: translateX(100%) rotate(45deg);
}
}
/* Add edge effect to card faces */
.card-front, .card-back {
position: absolute;
width: 100%;
height: 100%;
backface-visibility: hidden;
border-radius: 15px;
overflow: hidden;
}
/* Add edge highlight effect */
.card-front::before, .card-back::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
border: 2px solid rgba(255, 255, 255, 0.1);
border-radius: 15px;
box-shadow:
inset 0 0 15px rgba(0, 0, 0, 0.5),
0 0 5px rgba(255, 255, 255, 0.1);
z-index: 5;
}
/* Add side edge effect */
.card-front::after, .card-back::after {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: linear-gradient(
90deg,
rgba(0, 0, 0, 0.2) 0%,
rgba(0, 0, 0, 0.1) 2%,
rgba(0, 0, 0, 0) 5%,
rgba(0, 0, 0, 0) 95%,
rgba(0, 0, 0, 0.1) 98%,
rgba(0, 0, 0, 0.2) 100%
);
border-radius: 15px;
z-index: 4;
}
/* Add side thickness effect */
.card-front, .card-back {
position: absolute;
width: 100%;
height: 100%;
backface-visibility: hidden;
border-radius: 15px;
overflow: hidden;
box-shadow:
inset 0 0 20px rgba(0, 0, 0, 0.5),
0 0 10px rgba(0, 0, 0, 0.3);
}
/* Add side thickness with pseudo-elements */
.card-front::before, .card-back::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
border: 3px solid rgba(0, 0, 0, 0.3);
border-radius: 15px;
box-shadow:
inset 0 0 15px rgba(0, 0, 0, 0.5),
0 0 5px rgba(255, 255, 255, 0.1);
z-index: 5;
}
/* Add side thickness with additional pseudo-elements */
.card-front::after, .card-back::after {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: linear-gradient(
90deg,
rgba(0, 0, 0, 0.3) 0%,
rgba(0, 0, 0, 0.2) 2%,
rgba(0, 0, 0, 0) 5%,
rgba(0, 0, 0, 0) 95%,
rgba(0, 0, 0, 0.2) 98%,
rgba(0, 0, 0, 0.3) 100%
);
border-radius: 15px;
z-index: 4;
}
.card-front {
background-color: #ffffff;
display: flex;
justify-content: center;
align-items: center;
}
#card1 .card-front {
background: linear-gradient(145deg, #1a1a1a, #2a2a2a);
border: 2px solid #444;
}
#card2 .card-front {
background: linear-gradient(145deg, #350617, #8b0000);
border: 2px solid #c0392b;
}
#card3 .card-front {
background: linear-gradient(145deg, #0a3b0a, #1a5d1a);
border: 2px solid #2a782a;
}
#card4 .card-front {
background: linear-gradient(145deg, #7a1212, #c41e1e);
border: 2px solid #da2525;
}
#card5 .card-front {
background: linear-gradient(145deg, #252525, #323232);
border: 2px solid #555;
}
#card6 .card-front {
background: linear-gradient(145deg, #4f0a0a, #7b1111);
border: 2px solid #9b1010;
}
#card7 .card-front {
background: l.........完整代码请登录后点击上方下载按钮下载查看
网友评论0