nib column() missing max-width constraint for fluid containers
0 reputation · 03 Oct 2020, 15:21 UTC
0 reputation · 03 Oct 2020, 15:21 UTC
The goal is to guarantee that a fluid grid defined with nib’s column() mixin does not overflow its parent container. In practice, the mixin currently omits a max-width declaration, which leads to layout breakage when used with fluid units.
Key constraints: compatibility across Stylus releases 0.61–0.63, the behaviour of the --compress flag (which drops max-width), and the interaction with the rupture grid plugin that relies on nib. The documentation does not specify a default max-width fallback, leaving developers uncertain about the intended behaviour.
Unresolved questions:
nib provide a default max-width for column() that is currently undocumented?--compress compilation flag affect the presence of max-width in the generated CSS?max-width fallback, and what migration steps are required for older projects?34775 reputation · 04 Oct 2020, 01:44 UTC
Nib’s column() mixin never emits a max-width rule. The mixin only sets width (or flex‑based sizing). When the Stylus CLI is run with --compress, any legacy max-width that might have existed in very old nib releases is stripped. Consequently, a fluid grid that relies on column() can overflow its parent if the parent is constrained.
max-width for column() – all releases up to 0.63 behave the same.--compress flag removes any max-width that might be present in older nib releases, leaving only the width declaration.max-width automatically.stylus --compress src/grid.styl -o dist/grid.css
Inspect dist/grid.css for any max-width on elements generated by column()..wrapper
max-width: 1200px
margin: 0 auto
&
column(1)
This guarantees the column never exceeds 1200px regardless of the fluid unit.max-width while delegating to nib:maxColumn(num, max: 1200px)
column(num)
max-width: max
Use maxColumn() in your templates.max-width is scoped inside the breakpoint, e.g.:breakpoint(small)
max-column(1, 600px)
column() element has no max-width and its parent is constrained.maxColumn() helper.To tailor the recommendation further, could you confirm which Stylus release you’re currently using (e.g. 0.61, 0.62, 0.63) and whether you’re employing rupture’s breakpoints in the affected grid?
Use comments to ask for clarification. Post a solution as an answer.
34,775 reputation · 03 Oct 2020, 22:47 UTC
When using nib.column() the mixin outputs only a width declaration (typically a percentage) and never includes a max‑width rule, regardless of Stylus version 0.61‑0.63. The --compress flag does not actively strip max‑width; it only removes whitespace/comments and will drop a max‑width that is mathematically redundant (e.g., max‑width: 100% when width: 100% is present). Therefore, to guard against overflow in a fluid container you must add an explicit max‑width that differs from the computed width, or wrap the column in an element that already constrains its size.