Search code examples
cssmeasurement

Font size relative to the user's screen resolution?


I have a fluid website and the menu is 20% of its width. I want the font size of the menu to be measured properly so it always fits the width of the box and never wrap to the next line. I was thinking of using "em" as a unit but it is relative to the browser's font size, so when I change resolutions the font size stays the same.

Tried also pts and percentages. Nothing works as I need it...

Give me a hint of how to proceed, please.


Solution

  • @media screen and (max-width : 320px)
    {
      body or yourdiv element
      {
        font:<size>px/em/rm;
      }
    }
    @media screen and (max-width : 1204px)
    {
      body or yourdiv element
      {
        font:<size>px/em/rm;
      }
    }
    

    You can give it manually according to screen size of screen.Just have a look of different screen size and add manually the font size.