Problem: Fluid Typography with Scale Multipliers
Problem description
Given a section containing <h2> and <p>, write CSS rules to:
Define CSS custom properties
--min-root(16px) and--max-root(20px).Compute
--fluid-rootusingclamp()to interpolate between these values for viewport widths from320pxto1440px.Define multipliers:
--scale-2: 1.5; --scale-1: 1.2;.Apply fluid typography:
h2 { font-size: calc(var(--fluid-root) * var(--scale-2)); }p { font-size: calc(var(--fluid-root) * var(--scale-1)); }
Goal
Use CSS variables, clamp(), and calc() multiplication to build a fluid modular scale that adjusts typography proportionally.
Constraints
The solution must use an external stylesheet named
styles.css.Do not use JavaScript.
Support all modern browsers.
Viewport range should be between
320pxand1440px.The root font size must have a minimum of
16pxand a maximum of20px.Define multipliers as
--scale-2: 1.5and--scale-1: 1.2.
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 Typography with Scale Multipliers
Problem description
Given a section containing <h2> and <p>, write CSS rules to:
Define CSS custom properties
--min-root(16px) and--max-root(20px).Compute
--fluid-rootusingclamp()to interpolate between these values for viewport widths from320pxto1440px.Define multipliers:
--scale-2: 1.5; --scale-1: 1.2;.Apply fluid typography:
h2 { font-size: calc(var(--fluid-root) * var(--scale-2)); }p { font-size: calc(var(--fluid-root) * var(--scale-1)); }
Goal
Use CSS variables, clamp(), and calc() multiplication to build a fluid modular scale that adjusts typography proportionally.
Constraints
The solution must use an external stylesheet named
styles.css.Do not use JavaScript.
Support all modern browsers.
Viewport range should be between
320pxand1440px.The root font size must have a minimum of
16pxand a maximum of20px.Define multipliers as
--scale-2: 1.5and--scale-1: 1.2.
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.