js+css实现一个扑克牌deck游戏代码
代码语言:html
所属分类:游戏
代码描述:js+css实现一个扑克牌deck游戏代码,有洗牌动画。
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<link type="text/css" rel="stylesheet" href="//repo.bfw.wiki/bfwrepo/css/normalize.css">
<style>
@import url("https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;700&family=Noto+Color+Emoji&display=swap");
:root {
/* Card properties */
--card-width: 100px;
--card-height: 140px;
--card-border-radius: 10px;
--card-border: 2px solid #1a1a1a;
--card-bg: white;
--card-shadow: 2px 2px 8px rgba(0, 0, 0, 0.25);
--card-font: "Arial";
--card-transition: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
/* 3D properties */
--deck-perspective: 2000px;
--hover-scale: 1.1;
--hover-rotate-y: 5deg;
--hover-rotate-x: -5deg;
--hover-z: 50px;
--hover-shadow: 0 15px 30px rgba(0, 0, 0, 0.3);
--spread-distance: 250px;
--spread-angle: 60deg;
/* Font sizes */
--corner-font-size: 16px;
--center-font-size: 24px;
--face-font-size: 48px;
/* Color palette - classic casino */
--bg-color: #0c3b2e;
--bg-gradient: linear-gradient(135deg, #0c3b2e 0%, #145a44 100%);
--text-color: #f8f0e3;
--accent-color: #d4af37;
--accent-light: #f2d675;
--button-bg: rgba(212, 175, 55, 0.85);
--button-hover: rgba(212, 175, 55, 1);
--button-border: 1px solid #b4922c;
--header-bg: rgba(26, 26, 26, 0.9);
--footer-bg: rgba(26, 26, 26, 0.9);
--deck-bg: rgba(20, 90, 68, 0.7);
/* Texture URLs */
/* --felt-texture: url('https://www.transparenttextures.com/patterns/felt.png');
--card-texture: url('https://www.transparenttextures.com/patterns/cardboard-flat.png');*/
}
/* Base styles */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background: var(--bg-color);
background-image: var(--bg-gradient), var(--felt-texture);
font-family: "Playfair Display", serif;
font-weight: 400;
font-style: normal;
min-height: 100vh;
color: var(--text-color);
display: grid;
grid-template-rows: auto 1fr auto;
grid-template-areas:
"header"
"main"
"footer";
}
span {
font-family: "Noto Color Emoji", sans-serif;
font-weight: 400;
font-style: normal;
}
/* Header styles - classic casino */
header {
grid-area: header;
display: grid;
grid-template-columns: 1fr auto;
align-items: center;
padding: 1rem 2rem;
background: var(--header-bg);
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
border-bottom: 1px solid var(--accent-color);
}
h1 {
font-size: 2.5rem;
color: var(--accent-color);
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
font-family: "Playfair Display", serif;
letter-spacing: 1px;
font-weight: 700;
}
nav {
display: flex;
gap: 1rem;
}
/* Main content - classic casino */
main {
grid-area: main;
display: grid;
place-items: center;
padding: 2rem;
position: relative;
overflow: hidden;
}
main::before {
content: '';
position: absolute;
width: 100%;
height: 100%;
background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23d4af37' fill-opacity='0.1'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
opacity: 0.2;
z-index: -1;
}
.deck-container {
width: 100%;
max-width: 1200px;
height: 70vh;
display: grid;
grid-template-columns: 80px 1fr 80px;
place-items: center;
position: relative;
overflow: visible;
}
/* Table decorations */
.table-decoration {
width: 60px;
height: 60px;
border-radius: 50%;
background: var(--accent-color);
position: relative;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}
.table-decoration::before {
content: '';
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 40px;
height: 40px;
border-radius: 50%;
background: var(--bg-color);
border: 2px solid rgba(212, 175, 55, 0.5);
}
.table-decoration::after {
content: '';
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 20px;
height: 20px;
border-radius: 50%;
background: var(--accent-color);
}
.table-decoration.left {
justify-self: end;
}
.table-decoration.right {
justify-self: start;
}
/* Footer styles - classic casino */
footer {
grid-area: footer;
padding: 1rem;
text-align: center;
background: var(--footer-bg);
color: var(--accent-color);
font-size: 0.9rem;
border-top: 1px solid var(--accent-color);
}
/* Button styles - classic casino */
button {
background: var(--button-bg);
color: #1a1a1a;
border: var(--button-border);
padding: 0.75rem 1.5rem;
border-radius: 4px;
font-family: "Playfair Display", serif;
font-size: 1rem;
font-weight: bold;
cursor: pointer;
transition: all 0.3s ease;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
position: relative;
overflow: hidden;
letter-spacing: 1px;
text-transform: uppercase;
}
button:hover {
background: var(--button-hover);
transform: translateY(-3px);
box-shadow: 0 7px 10px rgba(0, 0, 0, 0.3);
}
button:active {
transform: translateY(1px);
box-shadow: 0 2px 3px rgba(0, 0, 0, 0.2);
}
button::after {
content: '';
position: absolute;
top: -50%;
left: -50%;
width: 200%;
height: 200%;
background: radial-gradient(circle, rgba(255,255,255,0.3) 0%, transparent 70%);
transform: scale(0);
opacity: 0;
transition: transform 0.5s, opacity 0.3s;
}
button:hover::after {
transform: scale(1);
opacity: 1;
}
/* Card deck - classic casino */
#deck {
width: 100%;
height: 100%;
display: grid;
place-items: center;
perspective: var(--deck-perspective);
transform-style: preserve-3d;
position: relative;
background: var(--deck-bg);
border-radius: 16px;
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2), inset 0 0 0 2px rgba(212, 175, 55, 0.3);
padding: 20px;
backdrop-filter: blur(5px);
border: 1px solid var(--accent-color);
/* Felt texture */
background-image:
linear-gradient(rgba(20, 90, 68, 0.7), rgba(20, 90, 68, 0.7)),
var(--felt-texture),
url("data:image/svg+xm.........完整代码请登录后点击上方下载按钮下载查看
















网友评论0