Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

font-size on mobile

I am using the HTML5 BoilerPlate.

I want to make the font-size of a certain block small ONLY on mobile devices.

I tried this, but it didn't work:

.searchresult {
    font-size: 0.5em;
    line-height: 1.4;
}
@media only screen and (min-width: 480px) {
    .search-result {
        font-size: 1em;
    }
}
@media only screen and (min-width: 768px) {
    .search-result {
        font-size: 1em;
    }
}
@media only screen and (min-width: 1140px) {
    .search-result {
        font-size: 1em;
    }
}

I thought making it ordinary size under the @media would work, but the font is small on my Mac and mobile.

I'd appreciate any help, thanks!

like image 247
Robert Dodd Avatar asked Mar 11 '13 08:03

Robert Dodd


People also ask

What font size is best for mobile?

Size. In general, the rule of thumb is that font size needs to be 16 pixels for mobile websites. Anything smaller than that could compromise readability for visually impaired readers.

Is 14px too small for mobile?

Optimal font sizes for mobile Body text - Font sizes should be at least 16px for body text. In some cases, you may be able to go smaller (for example. if a typeface has unusually large characters or you are using uppercase letters), with 14px being the smallest you should go.

What size should h1 be on mobile?

Display text (Heading 1) On mobile: 32px or 2em or smaller, since it uses up too much space. I use this as the maximum for my font sizes. For the other headings, you would pick some values in between that will still create a visual hierarchy. In most cases, you only need to style your <h1> to <h4> .

What is standard size font size?

Font size is commonly expressed in points. Font sizes range from 8 point (extremely small) to 72 point (extremely large). The standard font size for most documents is 12 point.


1 Answers

That is because you are using min-width

You Mac (probably big screen) & mobile is min-width 480 & 768 & 1140.

To make it for mobile & desktop different, you should do this (keeping your actual code):

.searchresult {
    font-size: 0.5em;
    line-height: 1.4;
}
@media only screen and (min-width: 480px) {
    .search-result {
        font-size: 1em;/* mobile font-size */
    }
}
@media only screen and (min-width: 768px) {
    .search-result {
        font-size: 1.4em;/*overrule for big screens*/
    }
}
@media only screen and (min-width: 1140px) {
    .search-result {
        font-size: 1.4em;/*another overrule for even bigger screens*/
    }
}
like image 62
Mark Avatar answered Nov 15 '22 06:11

Mark