Problem: Multi-Range Fluid Typography with Media Query Overrides
Problem description
Given a page with an <h1> and <p>, write CSS rules to:
Define CSS custom properties:
Mobile root font:
--min-root-mobile(14px) and--max-root-mobile(18px)Desktop root font:
--min-root-desktop(18px) and--max-root-desktop(24px)Scale multipliers:
--scale-h1(2.2) and--scale-p(1)
Compute
--fluid-root-mobileusingclamp()with interpolation for viewport widths from320pxto768px.Inside a
@media (min-width: 768px)block, compute--fluid-root-desktopusingclamp()for viewport widths from768pxto1440px.Apply
font-size: calc(var(--fluid-root-mobile) * var(--scale-h1))to<h1>on mobile, and inside the media query override to use--fluid-root-desktop.Similarly, set
<p>tocalc(var(--fluid-root-mobile) * var(--scale-p))and override in desktop.
Goal
Demonstrate advanced responsive typography by segmenting fluid scaling into multiple viewport ranges with breakpoint-specific interpolation.
Constraints
The solution must use an external stylesheet named
styles.css.Do not use JavaScript.
Support all modern browsers.
Mobile range should be
320px–768px; desktop range should be768px–1440px.Custom properties should be as specified.
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: Multi-Range Fluid Typography with Media Query Overrides
Problem description
Given a page with an <h1> and <p>, write CSS rules to:
Define CSS custom properties:
Mobile root font:
--min-root-mobile(14px) and--max-root-mobile(18px)Desktop root font:
--min-root-desktop(18px) and--max-root-desktop(24px)Scale multipliers:
--scale-h1(2.2) and--scale-p(1)
Compute
--fluid-root-mobileusingclamp()with interpolation for viewport widths from320pxto768px.Inside a
@media (min-width: 768px)block, compute--fluid-root-desktopusingclamp()for viewport widths from768pxto1440px.Apply
font-size: calc(var(--fluid-root-mobile) * var(--scale-h1))to<h1>on mobile, and inside the media query override to use--fluid-root-desktop.Similarly, set
<p>tocalc(var(--fluid-root-mobile) * var(--scale-p))and override in desktop.
Goal
Demonstrate advanced responsive typography by segmenting fluid scaling into multiple viewport ranges with breakpoint-specific interpolation.
Constraints
The solution must use an external stylesheet named
styles.css.Do not use JavaScript.
Support all modern browsers.
Mobile range should be
320px–768px; desktop range should be768px–1440px.Custom properties should be as specified.
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.