01 / 05
Fit any screen width
INPUT · Slides
Change the text size with the width too
02 / 05
All you write inside is font-size
The method is the one you know. Write the everyday size, then override it only when narrow.
There is no new way of writing here; you just put a font-size inside @media.
.title { font-size: 40px;}@media (max-width: 670px) { .title { font-size: 28px; }}03 / 05
Write the wide one first
The ordinary rule goes first and the @media goes after. The other way round, the ordinary rule that comes later overrides it and nothing happens.
Get the order wrong and it shows up as "I wrote it and nothing changed". Check the top and bottom of your CSS first.
04 / 05
Do not go too small
Shrinking makes it fit, but body text below 12px is hard work to read. Rough guides:
- big heading … 40px down to about 26px
- body text … 16px down to about 14px
Take a lot off headings and almost nothing off body text. Keeping the difference is what protects readability.
.lead { font-size: 18px;}@media (max-width: 670px) { .lead { font-size: 15px; }}05 / 05
Change the width and compare
Widen and narrow the preview and the text snaps at the dividing line. That line is the number you wrote in @media.
Have a go.