设置移动网页页面宽度的最佳设计实践是什么?

发布于 2024-08-11 23:13:11 字数 76 浏览 3 评论 0原文

不同手机上的不同浏览器有不同的屏幕分辨率。

社区中是否有最佳实践将宽度设置为标准尺寸,以便它适用于大多数现代手机和浏览器?

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

無心 2024-08-18 23:13:11

没有简单的方法可以确保跨移动浏览器的像素完美准确性(实际上,使用任何浏览器都没有简单的方法可以做到这一点)。然而,有一些方法可以帮助完成此类工作。例如,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.

我很OK 2024-08-18 23:13:11

恕我直言,最佳实践是对客户端设备的宽度和分辨率没有太多假设。

大多数这些设备都有专门用于显示/流动/缩小网页的浏览器。如果可能的话,让浏览器来完成这项工作。

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.

oО清风挽发oО 2024-08-18 23:13:11

您好,

我知道您的问题是决定选择适合所有手机的最佳屏幕尺寸,但这种方法很快就会对用户产生影响。

我关联的一个大型网站采用 UserAgent 字符串并将其规范化为一个公分母,例如,在英国针对特定的索尼爱立信手机类型使用了 300 多个不同的 UA 字符串,因此它们都被转换为相同的字符串,并且然后查找表以确定屏幕空间。

编码人员还可以访问当前的连接速度,该连接速度是由地理定位应用程序根据连接类型、路由类型等推导出来的。在请求时。您不想发送大量信息、高清媒体给连接速度较慢的人。

然后用它来

  1. 决定是否可以提供丰富的内容,然后
  2. 为内容选择最佳格式。

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

  1. decide if rich content can be served, and then
  2. select the optimum format for the content.

HTH

cheers,

明媚如初 2024-08-18 23:13:11

您始终可以使用“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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文