Skip to content

Commit 5e328f6

Browse files
committed
fix: resolve mobile layout issues (iOS zoom, overflow, date input sizing)
- Add font-size: 1rem on form inputs to prevent iOS Safari auto-zoom - Add min-width: 0 on body grid children to prevent content overflow - Add min-width: 0 and max-width: 100% on fieldset for narrow viewports - Add max-width: 100% on file input to contain iOS native rendering - Strip appearance on date/time inputs to fix iOS content-box override - Add min-height on inputs to prevent empty time input collapse on iOS
1 parent 988b049 commit 5e328f6

5 files changed

Lines changed: 22 additions & 0 deletions

File tree

demo/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,5 +463,6 @@ <h4><code>&lt;figure&gt;</code> element with a <code>&lt;picture&gt;</code> elem
463463
<footer>
464464
<p>nimble.css test page. Based on <a href="https://github.com/cbracco/html5-test-page">html5-test-page</a> by <a href="https://twitter.com/cbracco">@cbracco</a>.</p>
465465
</footer>
466+
466467
</body>
467468
</html>

specs/nimble-css.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,7 @@ body {
428428
}
429429
body > * {
430430
grid-column: 2;
431+
min-width: 0; /* allow grid children to shrink below intrinsic content width */
431432
}
432433
```
433434
@@ -622,6 +623,7 @@ Form elements are one of PicoCSS's strengths and Open Props normalize's weakness
622623
border-radius: var(--nc-radius);
623624
color: var(--nc-text);
624625
font: inherit;
626+
font-size: 1rem; /* >=16px prevents iOS Safari auto-zoom on focus */
625627
transition: border-color 0.2s, box-shadow 0.2s;
626628
}
627629

src/_document.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
body > * {
3232
grid-column: 2;
33+
min-width: 0; // Allow grid children to shrink below intrinsic content width
3334
}
3435

3536
// Selection styling using primary accent

src/_forms.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@
1414
--_input-bg: color-mix(in oklch, var(#{$prefix}surface-1), var(#{$prefix}surface-2) 20%);
1515

1616
padding: 0.5em 0.75em;
17+
min-height: calc(1em * 1.5 + 1em + 2px); // line-height + vertical padding + border
1718
background-color: var(--_input-bg);
1819
border: 1px solid var(#{$prefix}border);
1920
border-radius: var(#{$prefix}radius);
2021
color: var(#{$prefix}text-1);
2122
font: inherit;
23+
font-size: 1rem; // >=16px prevents iOS Safari auto-zoom on focus
2224
transition: border-color 0.2s, box-shadow 0.2s;
2325
}
2426

@@ -63,6 +65,8 @@
6365
border: 1px solid var(#{$prefix}border);
6466
border-radius: var(#{$prefix}radius);
6567
padding: var(#{$prefix}spacing);
68+
min-width: 0; // Override UA min-content default — prevents overflow on narrow viewports
69+
max-width: 100%;
6670
}
6771

6872
:where(legend) {
@@ -90,6 +94,7 @@
9094
color: var(#{$prefix}text-1);
9195
font: inherit;
9296
cursor: pointer;
97+
max-width: 100%; // Prevent native file input from overflowing container (iOS Safari)
9398
}
9499

95100
:where([type="file"])::file-selector-button {

src/_reset.scss

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,3 +181,16 @@
181181
}
182182

183183
}
184+
185+
// iOS Safari forces box-sizing: content-box and display: inline-flex on date/time
186+
// inputs, ignoring author box-sizing overrides. Stripping native appearance fixes
187+
// this and gives consistent sizing across browsers. The native picker still opens
188+
// on tap; only the decorative calendar/clock icon is removed.
189+
[type="date"],
190+
[type="month"],
191+
[type="week"],
192+
[type="time"],
193+
[type="datetime-local"] {
194+
-webkit-appearance: none;
195+
appearance: none;
196+
}

0 commit comments

Comments
 (0)