The viewport metatag (Mobile web part 1)
使用方式:
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
引入问题:
好了,你安定下来,学习如何编写一个为移动设备使用您的桌面网站建设知识网站。所以,你开始与一些非常基本的HTML。
<html>
<head>
<title>Hello world!</title>
</head>
<body>
<p>Hello world!</p>
</body>
</html>
好的!不能在简单了。你检查出来,它所有的桌面浏览器上看起来不错,然后你检查出来您的移动设备。
Hello World on the iPhone
天啊!哪里,我们出问题了吗?显然是没有放大阅读的文本。
这是在移动网站上的第一课:宽度是你的敌人。这是会在许多无数设备上遇到的宽度问题。
从逻辑上讲,它似乎很有道理:移动Safari在页面的,假设打开的是一个网站,并且会默认宽度是980px,这样,页面根据手机屏幕大小相应缩放,那么里面的内容也跟着缩放了。
Viewport
我们需要做的是告诉浏览器这个网页是为移动优化。这是viewport meta进入视野。
现在,我们调整我们的Hello World,只是有点...
<!doctype html>
<html>
<head>
<title>Hello world!</title>
<meta name="viewport" content="width=device-width"/>
</head>
<body>
<p>Hello world!</p>
</body>
</html>
正常了
好多了!通过设置视口的宽度等于“设备宽度”,我们基本上告诉它的设备宽度是320px,而不是默认980px,它猜中。如果我们设置宽度= 320将iPhone和其他一些智能手机上实现了相同的结果,但并不是所有的手机都有这个确切的宽度,所以最好简单地设置设备的宽度,并让手机浏览器弄清楚。
很多只智能手机都支持viewport metatag , iPhone , Android , webOS (Palm) ,Internet Explorer Mobile, Opera Mini , Opera Mobile.
More fun with the viewport tag
In addition to solving our biggest concern with the width of the content, the viewport tag has more options to play with:
Property |
Description |
width |
Width of the viewport in pixels (or device-width). If width isn’t set, it defaults to a desktop size (980px on mobile Safari). |
height |
Height of the viewport in pixels (or device-height). Generally you don’t need to worry about setting this property. |
initial-scale |
(0 to 10.0) Multiplier that sets the scale of the page after its initial display. Safe bet: if you need to set it, set it to 1.0. Larger values = zoomed in, smaller values = zoomed out |
minimum-scale |
(0 to 10.0) The minimum multiplier the user can “zoom out” to. Defaults to 0.25 on mobile Safari. |
maximum-scale |
(0 to 10.0) The minimum multiplier the user can “zoom in” to. Defaults to 1.6 on mobile Safari. |
user-scalable |
(yes/no) Whether to allow a user from scaling in/out (zooming in/out). Default to “yes” on mobile Safari.
|
以上文章翻译自:http://davidbcalhoun.com/2010/viewport-metatag
分享到:
相关推荐
Head First Mobile Web shows how to use the web tech- nology you’re already familiar with to make sites and apps that work on any device of any size. Put your JavaScript, CSS media query, and ...
With this hands-on book, veteran mobile and web developer Maximiliano Firtman demonstrates which aspects of your site or app slow down the user’s experience, and what you can do to achieve lightning...
With users increasingly accessing the web on mobile devices, it’s crucial to make sure your website is built to seamlessly fit this radical change in user behavior. Mobile Web Performance ...
High Performance Mobile Web 英文epub
Master Mobile Web Apps with jQuery Mobile(3rd) 英文zip 第3版 本资源转载自网络,如有侵权,请联系上传者或csdn删除 查看此书详细信息请在美国亚马逊官网搜索此书
移动Web的使用在呈爆炸式增长。很快,人们会更愿意在手机和平板电脑而不是PC机上浏览网页。你的企业需要一种移动策略,不过从哪里开始呢?本书会告诉你如何使用你熟悉的Web技术建立网站和应用,可以在各种任意大小的...
head first mobile web pdf(中文版)+源码
jQuery Mobile Web Development Essentials(3rd) 英文无水印原版pdf 第3版 pdf所有页面使用FoxitReader、PDF-XChangeViewer、SumatraPDF和Firefox测试都可以打开 本资源转载自网络,如有侵权,请联系上传者或...
Mobile web UI based on Vue and Weui 基于Vue和WeUI的移动Web视觉库.zip,Mobile UI Components based on Vue & WeUI
A Platform for Mobile Web Applications,适用于Qt的移动开发平台,比如安卓和IOS的开发说明文档。
Web 2.0 is hot nowadays. Mobile Web 2.0 is the hottest buzzword. Want to learn mobile web development, Have a look at this book
详细讲解如何使用Visual Studio 进行Mobile页面开发
Throughout the book, you’ll learn details that help you become a pro at mobile web development. You begin with simple HTML and quickly enhance it using jQuery Mobile for incredible mobile-optimized ...
* Accept payments online via mobile web and SMS using Paypal, SMS short codes, and more. * Integrate your application with SMS and MMS messages - enable users to send SMS and MMS messages to your ...
Today, mobile is a must for every company, but how you reach users will determinate success or ... The Mobile Web World Chapter 2. Where to measure performance Chapter 3. Optimizing for the first visit
如何使用ASP.NET Mobile Controls开发Mobile Web应用
WebCore Architectural Support for Mobile Web Browsing
如何使用ASP_NET Mobile Controls开发Mobile Web应用 pdf
Master Mobile Web Apps with jQuery Mobile