手机浏览网站时如何自动缩小?

发布于 2024-09-14 03:30:45 字数 96 浏览 7 评论 0原文

就我而言,我将 div 宽度设置为 500px

但在手机中浏览时它会自动缩小。

到底是如何实现的,它是特定于设备的吗?

In my case I made the div width 500px,

but it automatically zoomed out when browsed in a mobilephone

How's the magic done exactly,is it device specific?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

捂风挽笑 2024-09-21 03:30:45

您可能想在 html 页面的头部尝试类似的操作:

<meta name="viewport" content="width=device-width, initial-scale=1.0"/>

有关更多信息,请参见此处:
http://davidbcalhoun.com/2010/viewport-metatag

You might want to try something like this in the head of the html page:

<meta name="viewport" content="width=device-width, initial-scale=1.0"/>

For more info see here:
http://davidbcalhoun.com/2010/viewport-metatag

余罪 2024-09-21 03:30:45

编辑:下面的答案不再反映当前的正常做法。现在有一个相当完善的标准,称为元视口,它控制页面在移动设备上的缩放方式。如果没有这一点,网站将被视为“不适合移动设备”,并且移动浏览器会以典型的桌面宽度显示页面,然后缩小以显示全宽度。


这是特定于浏览器的。

它甚至是大多数移动浏览器(例如 Android、诺基亚 S60、Opera Mini)中的可配置选项。我更喜欢将其关闭,以便页面以正常的 100% 缩放打开(如果它被切断,我只需滚动)。

有些人喜欢立即看到整个页面宽度,即使文本太小而无法阅读,然后双击即可放大。

浏览器通常首先计算页面的总宽度。在此计算中,任何灵活宽度元素都被视为可以容纳其所有子元素的最小宽度。如果它小于或等于浏览器窗口的宽度,则不会进行缩放,但如果它更大,浏览器会将其设置为虚拟页面宽度,并且如果用户打开此选项,则会缩小所有内容(例如缩小)在现代桌面浏览器中),以便页面的最小宽度占据浏览器窗口的宽度。

Edit: the answer below no longer reflects current normal practice. There is now a fairly well established standard called the meta viewport which controls how the page is scaled on mobile. In the absence of this, sites are deemed "not mobile friendly" and mobile browsers show the page at typical desktop width, zoomed out to show full width.


It is browser specific.

It's even a configurable option in most mobile browsers (eg Android, Nokia S60, Opera Mini). I prefer to have it turned off, so that pages open with normal 100% zoom (and if it's cut off, I just scroll).

Some people prefer to see the whole page width at once even if the text is too small to read, then double-tap to zoom up after that.

The browser typically calculates the total width of the page first. In this calculation any flexible-width element is taken to be the minimum width which can fit all its children. If this is less or equal to the width of the browser window no scaling is done, but if it's greater, the browser sets this as the virtual page width and, if the user has turned this option on, scales everything down (like zooming out in a modern desktop browser) so that that minimum width of the page occupies the width of the browser window.

清风无影 2024-09-21 03:30:45

浏览器会做它想做的事。由于移动电话的屏幕较小,因此浏览器可能会缩小以使页面看起来更舒适。

The browser do whatever it wants to. Since mobile phones have a small screen probably this browser zoomed out to be more pleasant to look the page.

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