Font size with percentage value (%) not scaling with screen size

I think what you’re looking for are viewport percentage units.

Try this:

.about-content-title h1 { font-size: 5vw; }

With this adjustment, when you re-size the browser window the font will scale in size.

From the spec:

5.1.2. Viewport-percentage lengths: the vw, vh, vmin, vmax units

The viewport-percentage lengths are relative to the size of the
initial containing block. When the height or width of the initial
containing block is changed, they are scaled accordingly.

  • vw unit – Equal to 1% of the width of the initial containing block.
  • vh unit – Equal to 1% of the height of the initial containing
    block.
  • vmin unit – Equal to the smaller of vw or vh.
  • vmax unit – Equal to the larger of vw or vh.

Using percentage values (%) doesn’t scale your fonts relative to the viewport because these values are relative to a parent or ancestor. See the spec: 4.3. Percentages: the <percentage> type

Leave a Comment