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!
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.
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.
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> .
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.
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*/
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With