Problem: Viewport-Based Fluid Typography with Height Constraint
Problem description
Given a full-screen <section class="intro"> containing an <h1> and a <p>, write CSS rules to:
Define CSS custom properties:
--min-font:18px--max-font:48px--min-vw:320px--max-vw:1920px--min-vh:480px--max-vh:1080px
Compute a fluid font-size using a combination of the following:
clamp(--min-font, calc(1vw + 1vh), --max-font)Additionally, limit scaling so at extreme aspect ratios heading never exceeds
--max-fontor goes below--min-fontby usingclamp()nested withmin()ormax()as needed.
Apply this fluid size to
<h1>and set<p>to 60% of the computed<h1>size using relative units.
Goal
Ensure typography scales responsively considering both width and height constraints, avoiding overly large text on landscape screens and overly small text on portrait devices.
Constraints
The solution must use an external stylesheet named
styles.css.Do not use JavaScript.
Support modern browsers with
clamp(),min(), andmax()functions.Viewport width range should be
320px–1920px; height range should be480px–1080px.<p>uses0.6remrelative to the computed<h1>size.
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: Viewport-Based Fluid Typography with Height Constraint
Problem description
Given a full-screen <section class="intro"> containing an <h1> and a <p>, write CSS rules to:
Define CSS custom properties:
--min-font:18px--max-font:48px--min-vw:320px--max-vw:1920px--min-vh:480px--max-vh:1080px
Compute a fluid font-size using a combination of the following:
clamp(--min-font, calc(1vw + 1vh), --max-font)Additionally, limit scaling so at extreme aspect ratios heading never exceeds
--max-fontor goes below--min-fontby usingclamp()nested withmin()ormax()as needed.
Apply this fluid size to
<h1>and set<p>to 60% of the computed<h1>size using relative units.
Goal
Ensure typography scales responsively considering both width and height constraints, avoiding overly large text on landscape screens and overly small text on portrait devices.
Constraints
The solution must use an external stylesheet named
styles.css.Do not use JavaScript.
Support modern browsers with
clamp(),min(), andmax()functions.Viewport width range should be
320px–1920px; height range should be480px–1080px.<p>uses0.6remrelative to the computed<h1>size.
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.