Skip to content

Commit be639fa

Browse files
Refactor CSS styles for improved layout and accessibility
1 parent b9786f4 commit be639fa

File tree

1 file changed

+97
-30
lines changed

1 file changed

+97
-30
lines changed

css/style.css

Lines changed: 97 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,90 @@
1+
/* =========================
2+
Global Styles
3+
========================= */
4+
*,
5+
*::before,
6+
*::after {
7+
box-sizing: border-box;
8+
}
9+
110
body {
211
background: linear-gradient(90deg, #2563eb 60%, #1e40af 100%);
312
min-height: 100vh;
4-
font-family: 'Segoe UI';
13+
font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
514
margin: 0;
6-
padding: 0;
15+
padding: 16px; /* important for small screens */
16+
display: flex;
17+
align-items: center;
18+
justify-content: center;
719
}
820

9-
21+
/* =========================
22+
Form Container
23+
========================= */
1024
.form-container {
11-
background: #fff;
12-
width: 500px;
13-
/* center without margin */
14-
position: absolute;
15-
top: 50%;
16-
left: 50%;
17-
transform: translate(-50%, -50%);
18-
/* margin: 50px auto; */
19-
padding: 28px;
20-
border-radius: 12px;
25+
background: #ffffff;
26+
width: 100%;
27+
max-width: 500px;
28+
padding: 24px;
29+
border-radius: 14px;
2130
border: 2px solid #000000;
22-
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
31+
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
2332
}
2433

34+
/* =========================
35+
Heading
36+
========================= */
2537
h2 {
2638
text-align: center;
2739
color: #1a365d;
28-
margin-bottom: 18px;
40+
margin-bottom: 20px;
41+
font-size: 1.6rem;
2942
}
3043

44+
/* =========================
45+
Form Groups
46+
========================= */
3147
.form-group {
3248
margin-bottom: 16px;
3349
display: flex;
3450
flex-direction: column;
3551
}
3652

53+
/* =========================
54+
Labels
55+
========================= */
3756
label {
3857
margin-bottom: 6px;
3958
color: #2d3a4a;
4059
font-weight: 500;
60+
font-size: 0.95rem;
4161
}
4262

63+
/* =========================
64+
Inputs & Selects
65+
========================= */
4366
input[type="text"],
4467
input[type="email"],
4568
input[type="password"],
4669
input[type="number"],
4770
select {
48-
padding: 10px 12px;
71+
padding: 12px;
4972
border: 1.5px solid #bfc9d9;
50-
border-radius: 6px;
51-
font-size: 16px;
73+
border-radius: 8px;
74+
font-size: 1rem;
5275
background: #f9fbfd;
5376
outline: none;
54-
/* outline: none; used to remove the default focus outline */
77+
transition: border-color 0.2s ease, box-shadow 0.2s ease;
78+
}
79+
80+
/* Focus (keyboard & accessibility friendly) */
81+
input:focus,
82+
select:focus {
83+
border-color: #2563eb;
84+
box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25);
5585
}
5686

87+
/* Validation States */
5788
input.valid,
5889
select.valid {
5990
border-color: #10b981;
@@ -66,34 +97,70 @@ select.invalid {
6697
background: #fef2f2;
6798
}
6899

69-
/* Focused field highlight for JS-based focus highlighting */
100+
/* JS focus highlight */
70101
input.focused,
71102
select.focused {
72-
background: #c1dcff;
73-
box-shadow: 0 0 0 2px #15ff00;
103+
background: #e6f0ff;
104+
box-shadow: 0 0 0 3px rgba(21, 255, 0, 0.4);
74105
}
75106

107+
/* =========================
108+
Submit Button
109+
========================= */
76110
button[type="submit"] {
77111
width: 100%;
78-
padding: 12px;
112+
padding: 14px;
79113
background: linear-gradient(90deg, #2563eb 60%, #1e40af 100%);
80-
color: #fff;
114+
color: #ffffff;
81115
border: none;
82-
border-radius: 6px;
83-
font-size: 1.1rem;
116+
border-radius: 8px;
117+
font-size: 1.05rem;
84118
font-weight: 600;
85119
cursor: pointer;
86-
margin-top: 8px;
120+
margin-top: 10px;
121+
transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.2s ease;
87122
}
88123

89124
button[type="submit"]:hover {
90125
background: linear-gradient(90deg, #1e40af 60%, #2563eb 100%);
126+
box-shadow: 0 6px 14px rgba(0, 0, 0, 0.2);
127+
}
128+
129+
button[type="submit"]:active {
130+
transform: scale(0.98);
91131
}
92132

93-
/* for the checkBox */
133+
/* =========================
134+
Checkbox (Terms)
135+
========================= */
94136
.form-group.terms {
95-
/* Set flex-direction to row so the checkbox and its label appear side by side horizontally instead of stacked vertically */
96137
flex-direction: row;
97138
align-items: center;
98-
margin-bottom: 10px;
139+
gap: 8px;
140+
font-size: 0.9rem;
141+
}
142+
143+
.form-group.terms input {
144+
width: 18px;
145+
height: 18px;
146+
}
147+
148+
/* =========================
149+
Mobile Optimizations
150+
========================= */
151+
@media (max-width: 480px) {
152+
h2 {
153+
font-size: 1.4rem;
154+
}
155+
156+
.form-container {
157+
padding: 20px;
158+
border-radius: 12px;
159+
}
160+
161+
input,
162+
select,
163+
button {
164+
font-size: 1rem;
165+
}
99166
}

0 commit comments

Comments
 (0)