Skip to content

Commit 86e8fe0

Browse files
committed
Refactor CSS for improved layout and responsiveness
- Adjusted board.css to prevent overflow and ensure squares maintain proper dimensions. - Enhanced pieces.css with optimizations for animations and overflow handling. - Updated style.css to use viewport height for board size, added overflow properties, and ensured responsive design for mobile. - Maintained aspect ratio for chess board and refined mobile adjustments for better user experience.
1 parent 07bb445 commit 86e8fe0

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

css/board.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
border: 1px solid #000;
88
box-shadow: 0 8px 24px rgba(0,0,0,0.3);
99
position: relative;
10+
min-height: 0; /* Prevents overflow */
1011
}
1112

1213
/* Add board coordinates */
@@ -73,6 +74,8 @@
7374
position: relative;
7475
cursor: pointer;
7576
transition: all 0.15s ease;
77+
min-height: 0; /* Ensures squares don't expand too much */
78+
min-width: 0;
7679
}
7780

7881
.square:hover {

css/pieces.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
align-items: center;
1111
transition: transform 0.15s ease;
1212
position: relative;
13+
will-change: transform; /* Optimize for animations */
14+
max-height: 100%; /* Ensure pieces don't overflow */
15+
overflow: visible;
1316
}
1417

1518
.piece:hover {

css/style.css

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
:root {
2-
--board-size: min(90vw, 580px); /* Slightly reduce default board size */
2+
--board-size: min(80vh, 580px); /* Change to use viewport height instead of width for better scaling */
33
--light-square: #f0d9b5;
44
--dark-square: #b58863;
55
--selected-square: rgba(255, 255, 0, 0.3);
@@ -16,6 +16,11 @@
1616
--show-last-move: block; /* Default to show */
1717
}
1818

19+
html {
20+
height: 100%;
21+
overflow-y: auto;
22+
}
23+
1924
body {
2025
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
2126
display: flex;
@@ -27,6 +32,7 @@ body {
2732
background-color: var(--main-bg);
2833
color: var(--text-color);
2934
box-sizing: border-box;
35+
overflow-y: auto; /* Add overflow to ensure content is accessible */
3036
}
3137

3238
.game-container {
@@ -35,19 +41,25 @@ body {
3541
gap: 24px;
3642
justify-content: center;
3743
max-width: 1200px;
44+
margin-top: 20px;
45+
margin-bottom: 20px;
3846
}
3947

4048
.board-container {
4149
background-color: #222;
4250
padding: 12px;
4351
border-radius: 8px;
4452
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
53+
max-height: 90vh; /* Ensure it doesn't exceed viewport height */
54+
display: flex;
55+
flex-direction: column;
4556
}
4657

4758
.chess-board {
4859
box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
4960
border-radius: 2px;
5061
overflow: hidden;
62+
aspect-ratio: 1 / 1; /* Maintain square aspect ratio */
5163
}
5264

5365
.game-info {
@@ -174,14 +186,23 @@ body {
174186

175187
/* Responsive adjustments */
176188
@media (max-width: 900px) {
189+
:root {
190+
--board-size: min(85vw, 85vh); /* Adjust for mobile */
191+
}
192+
177193
body {
178-
align-items: center;
194+
align-items: flex-start; /* Align to top on mobile */
179195
padding: 10px;
180196
}
181197

182198
.game-container {
183199
flex-direction: column;
184200
align-items: center;
201+
margin-top: 10px;
202+
}
203+
204+
.board-container {
205+
max-height: none; /* Remove height constraint on mobile */
185206
}
186207

187208
.game-info {

0 commit comments

Comments
 (0)