Skip to content

Commit 0ea6cd9

Browse files
fix:修复准备页面样式问题
1 parent 0d08ca2 commit 0ea6cd9

File tree

6 files changed

+364
-28
lines changed

6 files changed

+364
-28
lines changed

src/components/editor/DifficultySettings.css

Lines changed: 56 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,10 @@
9292
/* Difficulty Grid */
9393
.difficulty-grid {
9494
display: grid;
95-
grid-template-columns: repeat(5, 1fr);
95+
grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
9696
gap: 16px;
97+
justify-content: center;
98+
align-items: stretch;
9799
}
98100

99101
.difficulty-card {
@@ -107,6 +109,12 @@
107109
transition: all 0.3s ease;
108110
text-align: center;
109111
min-height: 180px;
112+
min-width: 160px;
113+
max-width: 200px;
114+
width: auto;
115+
box-sizing: border-box;
116+
overflow: hidden;
117+
word-wrap: break-word;
110118
}
111119

112120
.difficulty-card:hover {
@@ -161,12 +169,17 @@
161169
font-size: 18px;
162170
color: #1f2937;
163171
font-weight: 600;
172+
word-wrap: break-word;
173+
overflow-wrap: break-word;
174+
hyphens: auto;
164175
}
165176

166177
.grid-size {
167178
font-size: 14px;
168179
color: #6b7280;
169180
font-weight: 500;
181+
word-wrap: break-word;
182+
overflow-wrap: break-word;
170183
}
171184

172185
.card-body {
@@ -194,12 +207,16 @@
194207
font-weight: 500;
195208
text-transform: uppercase;
196209
letter-spacing: 0.5px;
210+
word-wrap: break-word;
211+
overflow-wrap: break-word;
197212
}
198213

199214
.stat-value {
200215
font-size: 16px;
201216
font-weight: 600;
202217
color: #374151;
218+
word-wrap: break-word;
219+
overflow-wrap: break-word;
203220
}
204221

205222
.difficulty-desc {
@@ -214,15 +231,18 @@
214231
}
215232

216233
.selection-indicator {
217-
padding: 8px 12px;
234+
padding: 6px 8px;
218235
border-radius: 6px;
219-
font-size: 14px;
236+
font-size: 12px;
220237
font-weight: 500;
221238
text-align: center;
222239
transition: all 0.2s ease;
223240
margin-top: 8px;
224-
min-height: 24px;
225-
overflow: visible;
241+
min-height: 20px;
242+
overflow: hidden;
243+
word-wrap: break-word;
244+
overflow-wrap: break-word;
245+
line-height: 1.2;
226246
}
227247

228248
.selection-indicator:not(.active) {
@@ -536,17 +556,30 @@
536556
}
537557

538558
.difficulty-grid {
539-
grid-template-columns: repeat(2, 1fr);
559+
grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
540560
gap: 12px;
561+
justify-content: center;
541562
}
542563

543564
.shape-grid {
544565
grid-template-columns: 1fr;
545566
}
546567

547568
.difficulty-card {
548-
padding: 16px;
549-
min-height: 150px;
569+
padding: 14px 8px;
570+
min-height: 140px;
571+
min-width: 140px;
572+
max-width: none;
573+
font-size: 14px;
574+
}
575+
576+
.difficulty-info h4 {
577+
font-size: 16px;
578+
}
579+
580+
.selection-indicator {
581+
font-size: 11px;
582+
padding: 4px 6px;
550583
}
551584

552585
.difficulty-stats {
@@ -556,33 +589,39 @@
556589

557590
.stat-item {
558591
flex-direction: row;
592+
justify-content: space-between;
593+
align-items: center;
594+
}
595+
559596
.difficulty-grid {
560597
display: flex;
561598
flex-direction: row;
562599
justify-content: center;
563600
align-items: stretch;
564-
gap: 16px;
601+
gap: 12px;
565602
margin: 0 auto 12px auto;
566-
width: 80%;
567-
max-width: 100px;
603+
width: 90%;
604+
flex-wrap: wrap;
568605
}
606+
569607
.difficulty-card {
570608
display: flex;
571609
flex-direction: column;
572-
padding: 12px 6px;
610+
padding: 12px 8px;
573611
border: 2px solid #e5e7eb;
574612
border-radius: 12px;
575613
background: white;
576614
cursor: pointer;
577615
transition: all 0.3s ease;
578616
text-align: center;
579617
min-height: 120px;
580-
width: 50px;
581-
max-width: 10vw;
618+
min-width: 120px;
619+
max-width: 140px;
620+
width: auto;
621+
flex: 1;
582622
box-sizing: border-box;
583-
}
584-
justify-content: space-between;
585-
align-items: center;
623+
overflow: hidden;
624+
word-wrap: break-word;
586625
}
587626

588627
.settings-actions {

src/components/editor/DifficultySettings.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ export const DifficultySettings: React.FC<DifficultySettingsProps> = ({
206206
key={option.value}
207207
className={`difficulty-card ${selectedDifficulty === option.value ? 'selected' : ''}`}
208208
onClick={() => onDifficultyChange(option.value)}
209-
style={{ '--accent-color': option.color, width: 180, minWidth: 0, padding: '8px 2px' } as React.CSSProperties}
209+
style={{ '--accent-color': option.color, minWidth: 160, maxWidth: 200, width: 'auto', padding: '8px 4px', boxSizing: 'border-box' } as React.CSSProperties}
210210
>
211211
<div className="card-header">
212212
<span className="difficulty-icon">{option.icon}</span>

src/components/game/AnswerGrid.css

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
/* 添加以下属性确保高度固定 */
88
min-height: 0;
99
/* 重要:允许内容收缩 */
10-
10+
max-width: 100%;
11+
max-height: 100%;
12+
box-sizing: border-box;
1113
overflow: hidden;
1214
align-items: center; /* 新增:内容水平居中 */
1315
justify-content: center; /* 新增:内容垂直居中 */
@@ -33,11 +35,15 @@
3335

3436
.answer-grid {
3537
position: relative;
36-
flex: 1;
3738
display: grid;
3839
gap: 0px; /* 去除间隙,防止出现细线 */
3940
background: transparent; /* 去除背景色 */
4041
border-radius: 8px;
42+
max-width: 100%;
43+
max-height: 100%;
44+
width: fit-content;
45+
height: fit-content;
46+
box-sizing: border-box;
4147
padding: 0; /* 去除内边距 */
4248
z-index: 1;
4349

@@ -340,6 +346,13 @@
340346
display: grid;
341347
gap: 2px;
342348
padding: 2px;
349+
max-width: 100%;
350+
max-height: 100%;
351+
width: fit-content;
352+
height: fit-content;
353+
box-sizing: border-box;
354+
overflow: hidden;
355+
margin: auto;
343356
}
344357

345358
.triangle-square-container {
@@ -348,6 +361,11 @@
348361
border-radius: 4px;
349362
background: rgba(255, 255, 255, 0.8);
350363
overflow: hidden;
364+
box-sizing: border-box;
365+
width: 100%;
366+
height: 100%;
367+
max-width: 100%;
368+
max-height: 100%;
351369
}
352370

353371
.triangle-slot {

src/components/game/AnswerGrid.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,11 @@ export const AnswerGrid: React.FC<AnswerGridProps> = ({
7171
const maxCellHeight = Math.floor(availableHeight / gridSize.rows);
7272

7373
// 取较小值确保所有单元格都能显示
74-
const newSize = Math.min(maxCellWidth, maxCellHeight, 160); // 最大160px
74+
const newSize = Math.min(maxCellWidth, maxCellHeight, 140); // 最大140px (降低以避免溢出)
7575

76-
// 确保单元格大小合理
77-
const finalSize = Math.max(120, newSize); // 最小120px
76+
// 确保单元格大小合理,但对于小网格(如3x3)允许更小的尺寸
77+
const minSize = (gridSize.rows <= 3 && gridSize.cols <= 3) ? 80 : 100;
78+
const finalSize = Math.max(minSize, newSize);
7879

7980
setCellSize(finalSize);
8081
}, [gridSize.cols, gridSize.rows]);

src/components/game/PuzzleGame.css

Lines changed: 102 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,13 @@
109109
backdrop-filter: blur(4px); /* 轻微模糊,保持背景可见 */
110110
position: relative;
111111
z-index: 1; /* 确保在遮罩层之上 */
112+
box-sizing: border-box;
113+
overflow: visible;
114+
min-width: 0;
115+
display: flex;
116+
flex-direction: column;
117+
align-items: center;
118+
justify-content: center;
112119
}
113120

114121
/* 夜间模式下的内容区域 */
@@ -124,28 +131,53 @@
124131
font-size: 28px;
125132
font-family: 'Nunito', 'Quicksand', sans-serif;
126133
font-weight: 400;
134+
word-wrap: break-word;
135+
overflow-wrap: break-word;
136+
overflow: hidden;
137+
width: 100%;
138+
max-width: 100%;
139+
box-sizing: border-box;
140+
text-align: center;
141+
align-self: center;
127142
}
128143

129-
.puzzle-info {
144+
.start-content .puzzle-info {
130145
background: var(--light-pink);
131146
padding: 20px;
132147
border-radius: 12px;
133-
margin-bottom: 32px;
148+
margin: 0 20px 32px 20px !important;
134149
border: 2px solid var(--primary-pink);
135150
box-shadow: 0 4px 12px rgba(248, 165, 194, 0.2);
151+
width: auto !important;
152+
max-width: 200px !important;
153+
min-width: 180px;
154+
box-sizing: border-box;
155+
overflow: hidden;
156+
word-wrap: break-word;
157+
text-align: center;
158+
align-self: center;
136159
}
137160

138-
.puzzle-info p {
161+
.start-content .puzzle-info p {
139162
margin: 8px 0;
140163
color: var(--text-secondary);
141164
font-size: 16px;
142165
font-family: 'Nunito', 'Quicksand', sans-serif;
166+
word-wrap: break-word;
167+
overflow-wrap: break-word;
168+
white-space: normal;
169+
overflow: hidden;
143170
}
144171

145172
.start-actions {
146173
display: flex;
147174
gap: 12px;
148175
justify-content: center;
176+
width: 100%;
177+
max-width: 100%;
178+
box-sizing: border-box;
179+
flex-wrap: wrap;
180+
align-self: center;
149181
}
150182

151183
/* 主要按钮 */
@@ -580,6 +612,33 @@
580612

581613
/* 响应式设计 */
582614
@media (max-width: 768px) {
615+
.start-content {
616+
max-width: 350px;
617+
padding: 30px 20px;
618+
}
619+
620+
.start-content h2 {
621+
font-size: 24px;
622+
margin-bottom: 20px;
623+
}
624+
625+
.start-content .puzzle-info {
626+
padding: 16px;
627+
margin: 0 16px 24px 16px !important;
628+
max-width: 180px !important;
629+
min-width: 150px;
630+
width: auto !important;
631+
}
632+
633+
.start-content .puzzle-info p {
634+
font-size: 14px;
635+
margin: 6px 0;
636+
}
637+
638+
.start-actions {
639+
gap: 10px;
640+
}
641+
583642
.game-header {
584643
flex-direction: column;
585644
gap: 16px;
@@ -611,5 +670,45 @@
611670
.preview-footer {
612671
padding: 15px;
613672
}
673+
}
614674

675+
/* 小屏幕优化 */
676+
@media (max-width: 480px) {
677+
.puzzle-game-start {
678+
padding: 20px;
679+
}
680+
681+
.start-content {
682+
max-width: 300px;
683+
padding: 20px 16px;
684+
}
685+
686+
.start-content h2 {
687+
font-size: 20px;
688+
margin-bottom: 16px;
689+
}
690+
691+
.start-content .puzzle-info {
692+
padding: 12px;
693+
margin: 0 12px 20px 12px !important;
694+
max-width: 160px !important;
695+
min-width: 140px;
696+
width: auto !important;
697+
}
698+
699+
.start-content .puzzle-info p {
700+
font-size: 13px;
701+
margin: 4px 0;
702+
}
703+
704+
.start-actions {
705+
gap: 8px;
706+
flex-direction: column;
707+
align-items: center;
708+
}
709+
710+
.start-actions button {
711+
width: 100%;
712+
max-width: 200px;
713+
}
615714
}

0 commit comments

Comments
 (0)