Skip to content

Commit 478800d

Browse files
committed
不知道改了点啥
1 parent af65019 commit 478800d

1 file changed

Lines changed: 112 additions & 185 deletions

File tree

style.css

Lines changed: 112 additions & 185 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* 贪吃蛇游戏 - 极限美化CSS */
21
:root {
32
--primary: #6C63FF;
43
--secondary: #36D1DC;
@@ -65,6 +64,33 @@ body::before {
6564
animation: bgPulse 20s ease-in-out infinite alternate;
6665
}
6766

67+
/* 游戏标题样式 */
68+
h1 {
69+
text-align: center;
70+
margin-bottom: 2rem;
71+
background: linear-gradient(135deg, var(--primary), var(--secondary));
72+
-webkit-background-clip: text;
73+
background-clip: text;
74+
color: transparent;
75+
font-size: 3rem;
76+
font-weight: 800;
77+
letter-spacing: 1px;
78+
text-shadow: 0 5px 15px rgba(108, 99, 255, 0.2);
79+
position: relative;
80+
}
81+
82+
h1::after {
83+
content: '';
84+
position: absolute;
85+
bottom: -10px;
86+
left: 50%;
87+
transform: translateX(-50%);
88+
width: 100px;
89+
height: 4px;
90+
background: linear-gradient(to right, var(--primary), var(--secondary));
91+
border-radius: 2px;
92+
}
93+
6894
/* 游戏容器 */
6995
#game {
7096
background: linear-gradient(145deg,
@@ -104,6 +130,25 @@ body::before {
104130
z-index: 0;
105131
}
106132

133+
/* 游戏网格发光效果 */
134+
#game::after {
135+
content: '';
136+
position: absolute;
137+
top: -2px;
138+
left: -2px;
139+
right: -2px;
140+
bottom: -2px;
141+
background: linear-gradient(45deg,
142+
transparent,
143+
rgba(108, 99, 255, 0.1),
144+
rgba(54, 209, 220, 0.1),
145+
transparent);
146+
border-radius: 18px;
147+
z-index: -1;
148+
animation: borderGlow 4s linear infinite;
149+
pointer-events: none;
150+
}
151+
107152
/* 蛇身体样式 */
108153
.snake {
109154
background: linear-gradient(135deg,
@@ -236,23 +281,12 @@ button {
236281
min-width: 160px;
237282
}
238283

239-
/* 按钮图标 */
240-
button i {
241-
font-size: 1.2rem;
242-
transition: transform 0.3s ease;
243-
}
244-
245284
/* 按钮悬停效果 */
246285
button:hover {
247286
transform: translateY(-3px);
248287
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
249288
}
250289

251-
button:hover i {
252-
transform: scale(1.2);
253-
}
254-
255-
/* 按钮激活效果 */
256290
button:active {
257291
transform: translateY(-1px);
258292
}
@@ -358,71 +392,30 @@ button:focus:not(:active)::after {
358392
animation: statusPulse 3s ease-in-out infinite;
359393
}
360394

361-
/* 状态图标 */
362-
#status i {
363-
font-size: 1.5rem;
364-
color: var(--info);
365-
animation: iconFloat 3s ease-in-out infinite;
366-
}
367-
368-
/* 游戏标题样式 */
369-
.game-title {
370-
text-align: center;
371-
margin-bottom: 2rem;
372-
background: linear-gradient(135deg, var(--primary), var(--secondary));
373-
-webkit-background-clip: text;
374-
background-clip: text;
375-
color: transparent;
376-
font-size: 3rem;
377-
font-weight: 800;
378-
letter-spacing: 1px;
379-
text-shadow: 0 5px 15px rgba(108, 99, 255, 0.2);
380-
position: relative;
381-
}
382-
383-
.game-title::after {
384-
content: '';
395+
/* 键盘快捷键提示 */
396+
.shortcut-hint {
385397
position: absolute;
386-
bottom: -10px;
387-
left: 50%;
388-
transform: translateX(-50%);
389-
width: 100px;
390-
height: 4px;
391-
background: linear-gradient(to right, var(--primary), var(--secondary));
392-
border-radius: 2px;
393-
}
394-
395-
/* 分数显示 */
396-
.score-display {
397-
display: flex;
398-
gap: 2rem;
399-
margin: 1.5rem 0;
400-
justify-content: center;
401-
}
402-
403-
.score-item {
404-
text-align: center;
405-
padding: 1rem 2rem;
406-
background: var(--glass-bg);
407-
border-radius: 12px;
408-
border: 1px solid var(--glass-border);
409-
min-width: 120px;
398+
top: 10px;
399+
right: 10px;
400+
background: rgba(0, 0, 0, 0.5);
401+
padding: 5px 10px;
402+
border-radius: 20px;
403+
font-size: 0.8rem;
404+
color: rgba(255, 255, 255, 0.7);
405+
-webkit-backdrop-filter: blur(5px);
406+
backdrop-filter: blur(5px);
407+
display: none;
410408
}
411409

412-
.score-label {
413-
font-size: 0.9rem;
414-
color: rgba(255, 255, 255, 0.7);
415-
margin-bottom: 0.5rem;
416-
text-transform: uppercase;
417-
letter-spacing: 1px;
410+
@media (min-width: 1024px) {
411+
.shortcut-hint {
412+
display: block;
413+
}
418414
}
419415

420-
.score-value {
421-
font-size: 2rem;
422-
font-weight: 700;
423-
color: var(--secondary);
424-
text-shadow: 0 0 10px rgba(54, 209, 220, 0.5);
425-
font-family: 'Courier New', monospace;
416+
/* 游戏结束特效 */
417+
.game-over {
418+
animation: shake 0.5s ease-in-out;
426419
}
427420

428421
/* 动画定义 */
@@ -525,37 +518,6 @@ button:focus:not(:active)::after {
525518
}
526519
}
527520

528-
@keyframes iconFloat {
529-
530-
0%,
531-
100% {
532-
transform: translateY(0);
533-
}
534-
535-
50% {
536-
transform: translateY(-5px);
537-
}
538-
}
539-
540-
/* 游戏网格发光效果 */
541-
#game::after {
542-
content: '';
543-
position: absolute;
544-
top: -2px;
545-
left: -2px;
546-
right: -2px;
547-
bottom: -2px;
548-
background: linear-gradient(45deg,
549-
transparent,
550-
rgba(108, 99, 255, 0.1),
551-
rgba(54, 209, 220, 0.1),
552-
transparent);
553-
border-radius: 18px;
554-
z-index: -1;
555-
animation: borderGlow 4s linear infinite;
556-
pointer-events: none;
557-
}
558-
559521
@keyframes borderGlow {
560522
0% {
561523
opacity: 0;
@@ -570,56 +532,26 @@ button:focus:not(:active)::after {
570532
}
571533
}
572534

573-
/* 响应式设计 */
574-
@media (max-width: 768px) {
575-
#game {
576-
width: 90vw;
577-
height: 90vw;
578-
max-width: 400px;
579-
max-height: 400px;
580-
}
581-
582-
#control {
583-
flex-direction: column;
584-
align-items: center;
585-
}
586-
587-
button {
588-
width: 100%;
589-
max-width: 300px;
590-
}
591-
592-
.game-title {
593-
font-size: 2rem;
594-
}
595-
596-
.score-item {
597-
padding: 0.75rem 1rem;
598-
min-width: 100px;
599-
}
600-
601-
.score-value {
602-
font-size: 1.5rem;
603-
}
604-
}
605-
606-
@media (max-width: 480px) {
607-
body {
608-
padding: 1rem;
609-
}
535+
@keyframes shake {
610536

611-
#game {
612-
width: 95vw;
613-
height: 95vw;
537+
0%,
538+
100% {
539+
transform: translateX(0);
614540
}
615541

616-
.game-title {
617-
font-size: 1.8rem;
542+
10%,
543+
30%,
544+
50%,
545+
70%,
546+
90% {
547+
transform: translateX(-5px);
618548
}
619549

620-
#status {
621-
font-size: 0.9rem;
622-
padding: 1rem;
550+
20%,
551+
40%,
552+
60%,
553+
80% {
554+
transform: translateX(5px);
623555
}
624556
}
625557

@@ -653,51 +585,46 @@ body>* {
653585
animation-delay: 0.3s;
654586
}
655587

656-
/* 键盘快捷键提示 */
657-
.shortcut-hint {
658-
position: absolute;
659-
top: 10px;
660-
right: 10px;
661-
background: rgba(0, 0, 0, 0.5);
662-
padding: 5px 10px;
663-
border-radius: 20px;
664-
font-size: 0.8rem;
665-
color: rgba(255, 255, 255, 0.7);
666-
-webkit-backdrop-filter: blur(5px);
667-
backdrop-filter: blur(5px);
668-
display: none;
669-
}
588+
/* 响应式设计 */
589+
@media (max-width: 768px) {
590+
#game {
591+
width: 90vw;
592+
height: 90vw;
593+
max-width: 400px;
594+
max-height: 400px;
595+
}
670596

671-
@media (min-width: 1024px) {
672-
.shortcut-hint {
673-
display: block;
597+
#control {
598+
flex-direction: column;
599+
align-items: center;
674600
}
675-
}
676601

677-
/* 游戏结束特效 */
678-
.game-over {
679-
animation: shake 0.5s ease-in-out;
680-
}
602+
button {
603+
width: 100%;
604+
max-width: 300px;
605+
}
681606

682-
@keyframes shake {
607+
h1 {
608+
font-size: 2rem;
609+
}
683610

684-
0%,
685-
100% {
686-
transform: translateX(0);
611+
#status {
612+
font-size: 0.9rem;
613+
padding: 1rem;
687614
}
615+
}
688616

689-
10%,
690-
30%,
691-
50%,
692-
70%,
693-
90% {
694-
transform: translateX(-5px);
617+
@media (max-width: 480px) {
618+
body {
619+
padding: 1rem;
695620
}
696621

697-
20%,
698-
40%,
699-
60%,
700-
80% {
701-
transform: translateX(5px);
622+
#game {
623+
width: 95vw;
624+
height: 95vw;
625+
}
626+
627+
h1 {
628+
font-size: 1.8rem;
702629
}
703630
}

0 commit comments

Comments
 (0)