简体   繁体   English

默认情况下,我的网站会在手机上缩小

[英]Get my website to be zoomed out by default on mobile phones

So I want users to be able to see my background on my website. 所以我希望用户能够在我的网站上看到我的背景。 Currently my websites width is 925px and when you view the website in a mobile browser (eg iPhone, Opera Mini) it is zoomed in on the text and the user can't see the background. 目前我的网站宽度为925px ,当您在移动浏览器(例如iPhone,Opera Mini)中查看网站时,它会放大文本并且用户无法看到背景。

I've tried using the meta viewport tag unsuccessfully. 我尝试过使用meta viewport标记失败了。 How do I get my website to be zoomed out by default on mobile browsers? 如何在移动浏览器上默认缩小我的网站?

EDIT: 编辑:

Here is the code I've tried so far: 这是我到目前为止尝试过的代码:

<meta name = "viewport" content = "width = device-width">

I know this is an old question, but I am answering anyway in case someone else needs the answer. 我知道这是一个老问题,但无论如何我都会回答以防其他人需要答案。

As of September 2011, Opera Mini is still using version 2.5 of the Presto rendering engine. 截至2011年9月,Opera Mini仍在使用Presto渲染引擎的2.5版本。 Viewport isn't available in Opera until Presto 2.7. 在Presto 2.7之前,Opera不提供Viewport。 (Opera Mobile, our smart phone browser does support viewport.) (Opera Mobile,我们的智能手机浏览器确实支持视口。)

Try this: 尝试这个:

<meta name="viewport" content="initial-scale=0.25">

When you include width=device-width , the browser 'magically'** finds the content area and adjusts it to fill the width of the device. 当你包括width=device-width ,浏览器'神奇地'**找到内容区域并调整它以填充设备的宽度。 If you want the background to peek through, you'll need to shrink the entire page to fit within the viewport. 如果您想要查看背景,则需要缩小整个页面以适合视口。

Leaving <meta name=viewport> out entirely will also work, but you will typically see less of the background image. 完全退出<meta name=viewport>也可以,但通常会看到较少的背景图像。

Ideally, however, you should also use media queries to create a site that works at a variety of widths. 但是,理想情况下,您还应该使用媒体查询来创建以各种宽度工作的网站。

** Using heuristics of some kind that a browser developer would be able to explain better than I can. **使用浏览器开发人员能够比我更好地解释的某种启发式方法。

After much trial and error I got the following to work correctly on iPhone 5.0.1 and Android 2.3.6. 经过多次试验和错误后,我得到以下内容才能在iPhone 5.0.1和Android 2.3.6上正常运行。 The site was designed for a 480 width. 该网站设计为480宽度。 Depending on the width of your site you have to play around with the width value for the iPhone. 根据您网站的宽度,您必须使用iPhone的宽度值。

<meta name="viewport" content="width=520, target-densitydpi=high-dpi" />
<meta http-equiv="Content-Type" content="application/vnd.wap.xhtml+xml; charset=utf-8" />
<meta name="HandheldFriendly" content="true" />
<meta name="apple-mobile-web-app-capable" content="yes" /> 

I'm surprised meta viewport didn't work for you (on Mobile Safari). 我很惊讶meta viewport不适合你(在Mobile Safari上)。 Can you post what you used? 你能发布你用过的东西吗?

UPDATE : This generally works for me... give it a try: 更新 :这通常适合我...尝试一下:

<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0" />

If that works, you can then start playing with the scale values to let users zoom if they want to, and by how much. 如果可以,那么您可以开始使用比例值来让用户根据需要进行缩放,以及使用多少。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM