设置移动网页页面宽度的最佳设计实践是什么?
不同手机上的不同浏览器有不同的屏幕分辨率。
社区中是否有最佳实践将宽度设置为标准尺寸,以便它适用于大多数现代手机和浏览器?
Different browsers on different phones have different screen resolution.
Is there a best practice in the community to set the width to a standard size, so that it works on most moderns phones and browsers?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
没有简单的方法可以确保跨移动浏览器的像素完美准确性(实际上,使用任何浏览器都没有简单的方法可以做到这一点)。然而,有一些方法可以帮助完成此类工作。例如,iPhone 的移动 Safari 支持“视口”元标记,允许您指定宽度等属性。以下是一些用法示例:
<
meta name="viewport" content="initial-scale= 2.5、user-scalable=no" />
苹果有一些信息此处,您将在网络上找到更多信息。
There's no easy way to ensure pixel-perfect accuracy across mobile browsers (actually, there's no easy way to do that with any browser). There are, however, some methods to help with that kind of work. For example, mobile Safari for the iPhone supports a 'viewport' meta tag that allows you to specify attributes like width. Here are some examples of usage:
<meta name="viewport" content="width = 750px" />
<meta name="viewport" content="initial-scale=2.5, user-scalable=no" />
Apple has some information here, and you'll find a lot more information across the web.
恕我直言,最佳实践是对客户端设备的宽度和分辨率没有太多假设。
大多数这些设备都有专门用于显示/流动/缩小网页的浏览器。如果可能的话,让浏览器来完成这项工作。
IMHO the best practise is to get along without too many assumptions about width and resolution of the clients device.
Mostly those devices have browsers geared towards displaying/flowing/reducing webpages. If at all possible, let the browser do the work.
您好,
我知道您的问题是决定选择适合所有手机的最佳屏幕尺寸,但这种方法很快就会对用户产生影响。
我关联的一个大型网站采用 UserAgent 字符串并将其规范化为一个公分母,例如,在英国针对特定的索尼爱立信手机类型使用了 300 多个不同的 UA 字符串,因此它们都被转换为相同的字符串,并且然后查找表以确定屏幕空间。
编码人员还可以访问当前的连接速度,该连接速度是由地理定位应用程序根据连接类型、路由类型等推导出来的。在请求时。您不想发送大量信息、高清媒体给连接速度较慢的人。
然后用它来
HTH
欢呼,
G'day,
I know you're question is to decide on making a selection of the optimum screen size to work on all phones but that approach soon wears thin with users.
A large web site I'm associated with takes the UserAgent string and normalises it to a common denominator, e.g. over 300 different UA strings in use in the UK for a particular Sony Ericsson phone type so they all get converted to the same string, and then does a lookup into a table to determine screen real estate.
The coders also have access to the current connection speed which is deduced by a geolocation application based on connection type, routing type, etc. at the time of the request. You don't want to be sending rich, high-def media to someone with a slow connection.
This is then used to
HTH
cheers,
您始终可以使用“em”而不是像素,它们应该正确缩放。
这仍然是一个敏感的话题,因为许多移动浏览器基本上会根据开发人员想要如何解释来解释您所拥有的内容。
You could always use "ems" instead of pixels they should scale properly.
This is still a touchy subject since many mobile browsers basically interpret what you have depending on how the devs wanted to make it interpret.