4

I have an application that runs on Android and IOS.
The application has some WebView components that displays HTML
From what I found there are "em" and "viewport" units as well as "@media" in css.

I'm new to HTML5 and CSS3, can someone, please, show me an example of responsive font size for mobile devices.
The most important for me is to have a different font size between mobile phones and tablets, but also between different screen size of mobile devices (for portrait and landscape orientations).

EDIT:

The WebView component are not full screen, they in size of a textbox and the size is dynamic.

NickF
  • 5,637
  • 12
  • 44
  • 75

3 Answers3

8

Use in media queries

HTML

<p class="fonts">Administrator</p>

Add media queries

  @charset "utf-8";
    /* CSS Document */
    /* Smartphones (portrait and landscape) ----------- */
    @media only screen
    and (min-device-width : 320px)
    and (max-device-width : 480px) {
     .fonts
     {
      font-size: 75%;
     }    
    }
    /* Smartphones (landscape) ----------- */
    @media only screen
    and (min-width : 321px) {
     .fonts
     {
      font-size: 120%;
     }  
    }
    /* Smartphones (portrait) ----------- */
    @media only screen
    and (max-width : 320px) {
     .fonts
     {
      font-size: 120%;
     }  
    }
    /* iPads (portrait and landscape) ----------- */
    @media only screen
    and (min-device-width : 768px)
    and (max-device-width : 1024px) {
     .fonts
     {
      font-size: 120%;
     }    
    }
    /* iPads (landscape) ----------- */
    @media only screen
    and (min-device-width : 768px)
    and (max-device-width : 1024px)
    and (orientation : landscape) {
     .fonts
     {
      font-size: 150%;
     }    
    }
    /* iPads (portrait) ----------- */
    @media only screen
    and (min-device-width : 768px)
    and (max-device-width : 1024px)
    and (orientation : portrait) {

     .fonts
     {
      font-size: 120%;
     }  
    }
    /* Desktops and laptops ----------- */
    @media only screen
    and (min-width : 1224px) {
     .fonts
     {
      font-size: 156%;
     }    
    }
    /* Large screens ----------- */
    @media only screen
    and (min-width : 1824px) {
     .fonts
     {
      font-size: 200%;
     }    
    }
    /* iPhone 4 ----------- */
    @media
    only screen and (-webkit-min-device-pixel-ratio : 1.5),
    only screen and (min-device-pixel-ratio : 1.5) {
     .fonts
     {
      font-size: 190%;
     }    
    }

I use % for font size, here is just example of fonts size, try it and add % what you think is the best

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Miomir Dancevic
  • 6,726
  • 15
  • 74
  • 142
0

Simplest way is to use dimensions in % or em. Just let base font size to default of the device and rest all in em.

Look at all the ways at https://stackoverflow.com/a/21981859/406659

Community
  • 1
  • 1
aWebDeveloper
  • 36,687
  • 39
  • 170
  • 242
0
.fonts
  {
    font-size: 5vw;
  } 

"VW" is Responsively displayed.