修复在移动Safari(iPhone)上的字体大小问题,其中文本呈现不一致,一些字体比其他字体大? [英] Fix font size issue on Mobile Safari (iPhone) where text is rendered inconsistently and some fonts are larger than others?

查看:714
本文介绍了修复在移动Safari(iPhone)上的字体大小问题,其中文本呈现不一致,一些字体比其他字体大?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的网站在移动Safari上呈现的字体大小不一致,据我们所知,只有Mobile Safari。



我们使用Firebug分析了网站,不正确的区域继承了正确的样式,但是字体仍然呈现错误的大小。



1)访问 http://www.panabee.com 。 p>

2)搜索域名。



左侧框显示不正确的字体大小。字体大小应与右侧的字体大小匹配(包括标题和盒子复制)。例如,标题Variations和Twitter比标题Alternate Endings大得多。



任何线索为什么?

解决方案

移动Safari(如Chrome for Android,Mobile Firefox和IE Mobile)会随时增加宽块的字体大小,双击以放大该块(使块适合屏幕宽度),文本将清晰易读。如果您设置 -webkit-text-size-adjust:100%(或 none ),能够做到这一点,因此当用户双击放大宽块时,文本将会非常小;用户将能够读取它,如果他们捏放大,但然后文本将比屏幕更宽,他们必须水平平移阅读每行文本!


  1. 理想情况下,您可以使用响应式网页设计技术,使您的设计适应移动屏幕尺寸(在这种情况下,您不会有任何非常宽的块,因此移动浏览器将不再调整您的字体大小)。


  2. 如果这不是一个选项,而且您仍然为移动用户投放了桌面版网站,请查看是否可以调整设计,使文本块不会超过移动设备的设备宽度(例如320px为许多肖像手机)(你可以使用移动特定的CSS以避免影响桌面浏览器),那么Mobile Safari不需要增加任何字体大小(和浏览器回流文本,如Android浏览器和Opera移动,也赢了


  3. 最后,如果您真的需要阻止Mobile Safari调整您的字体大小,设置 -webkit-text-size-adjust:100%,但这仅作为最后手段,因为这可能会导致移动用户很难阅读你的文本,因为它会太小,或者他们将不得不从一侧到另一侧之后,他们阅读的每一行。请注意,您必须使用 100%而不是 none ,因为没有在桌面浏览器中有讨厌的副作用。还有等价的 -moz-text-size-adjust -ms-text-size-adjust Firefox和IE Mobile。


编辑:例如在您的情况下,最简单的可能是第二选择,尝试添加以下CSS:

  / *仅限移动浏览器* / 
@media只有屏幕和-width:480px){
table#all_results {
width:auto;
}
td#main_box {
width:320px;
}
td#side_box {
width:320px;
}
}

您可以通过使用各种CSS媒体查询,或从JavaScript获取设备宽度。


Our site renders with inconsistent font sizes on mobile Safari -- and as far as we can tell, only Mobile Safari. This very much has stumped us.

We analyzed the site with Firebug, and the incorrect areas are inheriting the right styles, yet the fonts are still rendered with the wrong sizes.

1) Visit http://www.panabee.com.

2) Conduct a search for a domain name.

The boxes on the left side show the incorrect font sizes. The font size should match the font size on the right side (both box titles and box copy). For instance, the titles, "Variations" and "Twitter," are much larger than the title, "Alternate Endings."

Any clue why?

解决方案

Mobile Safari (like Chrome for Android, Mobile Firefox and IE Mobile) increases the font size of wide blocks (at all times), such that if you double-tap to zoom in on that block (which fits the block to the screen width), the text will be legible. If you set -webkit-text-size-adjust: 100% (or none), it won't be able to do this, and so when a user double-taps to zoom in on wide blocks the text will be illegibly small; users will be able to read it if they pinch-zoom in, but then the text will be wider than the screen and they'll have to pan horizontally to read each line of text!

  1. Ideally you would fix this by using Responsive Web Design techniques to make your design adapt to mobile screen sizes (in which case you would no longer have any very wide blocks, so mobile browsers would no longer adjust your font sizes).

  2. If that's not an option, and you're stuck serving a desktop site to mobile users, then see if you can tweak your design so none of your blocks of text are wider than the mobile device's device-width (e.g. 320px for many portrait phones) (you can use mobile-specific css to avoid affecting desktop browsers), then Mobile Safari won't need to increase any font sizes (and browsers which reflow text, like the Android Browser and Opera Mobile, also won't need to change your layout).

  3. Finally if you really need to prevent Mobile Safari from adjusting your font sizes you can set -webkit-text-size-adjust: 100%, but do this only as a last resort since it is likely to cause mobile users to have difficulty reading your text, as it'll either be too small or they'll have to pan from side to side after every line they read. Note that you must use 100% not none because none has nasty side-effects in desktop browsers. There are also equivalent -moz-text-size-adjust and -ms-text-size-adjust properties for Mobile Firefox and IE Mobile.

Edit: for example in your case the simplest is probably the 2nd alternative, so you could try adding the following CSS:

/* Mobile browsers only */
@media only screen and (max-device-width: 480px) {
    table#all_results {
        width: auto;
    }
    td#main_box {
        width: 320px;
    }
    td#side_box {
        width: 320px;
    }
}

Though it's not ideal to hardcode 320px like this; you could improve on that by using a variety of CSS media queries, or getting the device-width from JavaScript.

这篇关于修复在移动Safari(iPhone)上的字体大小问题,其中文本呈现不一致,一些字体比其他字体大?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆