Using px
s in your media queries assumes a set font-size
. This means that, in some browsers, things can break pretty quickly if the user has set a larger default font-size
or manually increases the font on your site. (It is worth noting that some browsers will require a refresh to render properly if the font-size
is increased after the page has already loaded.)
The way to avoid this is to use em
s instead of px
s. Em
s are based on the font-size
of their parent container and so when the font increases so does the container it lives in.
Another option similar to em
s is to use rem
s (which stands for "root em
s"). Rem
s, like em
s, are based on font-size
, but instead of using the font-size
of the parent container, rem
s are calculated based on the root font-size
- that is the font-size
of the html
tag.
Whether you use em
s or rem
s, by creating a fluid system of proportions rather than rigid (px
) layout, things keep working and are rea