Problem: Fluid Modular Scale with CSS Variables
Problem description
Given a hero section with an <h1> and a <p>, write CSS rules to:
Define CSS custom properties
--min-root(16px) and--max-root(24px).Create a fluid root font size between these values for viewport widths from
360pxto1200px.Apply this fluid root size to the document’s base (
body { font-size: var(--fluid-root); }).Set the
<h1>font size to2.5remand<p>to1remso they scale proportionally.
Goal
Leverage CSS variables and calc() within clamp() to establish a base font size that scales fluidly, and use rem units to maintain typographic proportions.
Constraints
The solution must use an external stylesheet named
styles.css.Do not use JavaScript.
Support all modern browsers.
Define custom properties:
--min-root: 16px; --max-root: 24px;.Apply the fluid range between viewport widths of
360pxand1200px.Style
<h1>at2.5remand<p>at1rem.
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 Modular Scale with CSS Variables
Problem description
Given a hero section with an <h1> and a <p>, write CSS rules to:
Define CSS custom properties
--min-root(16px) and--max-root(24px).Create a fluid root font size between these values for viewport widths from
360pxto1200px.Apply this fluid root size to the document’s base (
body { font-size: var(--fluid-root); }).Set the
<h1>font size to2.5remand<p>to1remso they scale proportionally.
Goal
Leverage CSS variables and calc() within clamp() to establish a base font size that scales fluidly, and use rem units to maintain typographic proportions.
Constraints
The solution must use an external stylesheet named
styles.css.Do not use JavaScript.
Support all modern browsers.
Define custom properties:
--min-root: 16px; --max-root: 24px;.Apply the fluid range between viewport widths of
360pxand1200px.Style
<h1>at2.5remand<p>at1rem.
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.