Problem: Fluid Vertical Rhythm System
Problem description
Given an article container with multiple headings (<h1> and <h2>) and paragraphs (<p>), write CSS rules to:
Define
CSScustom properties:--min-root (16px)and--max-root (20px)--min-line-height (1.4)and--max-line-height (1.8)--spacing-multiplier (1.5)
Compute a fluid root
font-size--fluid-rootusingclamp()and a linear interpolation for viewport widths from360pxto1440px.Compute a fluid
line-height--fluid-linebetween--min-line-heightand--max-line-heightusingclamp().Compute a fluid spacing unit
--fluid-spaceascalc(var(--fluid-root) * var(--spacing-multiplier)).Apply
--fluid-rootto the document’sfont-size,--fluid-lineto theline-height, and--fluid-spaceasmargin-bottomto eachheadingandparagraph.Provide a fallback in an
@supports not (font-size: clamp(1rem, 1vw + 1rem, 2rem))block that sets static sizes as follows:root = 16pxline-height = 1.4spacing = calc(16px * 1.5)
Goal
Ensure a harmonious vertical rhythm, consistent spacing and readable text, by fluidly scaling typography and margins across different viewport widths.
Constraints
The solution must use an external stylesheet named
styles.css.Do not use JavaScript.
Support modern browsers with
clamp()and legacy via@supports not.Viewport widths should be between
360pxand1440px.Custom properties should be as follows:
--min-root: 16px; --max-root: 20px;--min-line-height: 1.4; --max-line-height: 1.8;--spacing-multiplier: 1.5;
Sample visual output
Here’s what the output would look like:
Good luck trying the problem! If you’re unsure how to proceed, check the Solution.
Problem: Fluid Vertical Rhythm System
Problem description
Given an article container with multiple headings (<h1> and <h2>) and paragraphs (<p>), write CSS rules to:
Define
CSScustom properties:--min-root (16px)and--max-root (20px)--min-line-height (1.4)and--max-line-height (1.8)--spacing-multiplier (1.5)
Compute a fluid root
font-size--fluid-rootusingclamp()and a linear interpolation for viewport widths from360pxto1440px.Compute a fluid
line-height--fluid-linebetween--min-line-heightand--max-line-heightusingclamp().Compute a fluid spacing unit
--fluid-spaceascalc(var(--fluid-root) * var(--spacing-multiplier)).Apply
--fluid-rootto the document’sfont-size,--fluid-lineto theline-height, and--fluid-spaceasmargin-bottomto eachheadingandparagraph.Provide a fallback in an
@supports not (font-size: clamp(1rem, 1vw + 1rem, 2rem))block that sets static sizes as follows:root = 16pxline-height = 1.4spacing = calc(16px * 1.5)
Goal
Ensure a harmonious vertical rhythm, consistent spacing and readable text, by fluidly scaling typography and margins across different viewport widths.
Constraints
The solution must use an external stylesheet named
styles.css.Do not use JavaScript.
Support modern browsers with
clamp()and legacy via@supports not.Viewport widths should be between
360pxand1440px.Custom properties should be as follows:
--min-root: 16px; --max-root: 20px;--min-line-height: 1.4; --max-line-height: 1.8;--spacing-multiplier: 1.5;
Sample visual output
Here’s what the output would look like:
Good luck trying the problem! If you’re unsure how to proceed, check the Solution.