设为首页 收藏本站
查看: 468|回复: 0

转载:The IE Mobile Viewport on Windows Phone 7

[复制链接]

尚未签到

发表于 2015-5-12 11:09:38 | 显示全部楼层 |阅读模式
  One of the main challenges involved with mobile Web development is getting content to lay out correctly on screens of varying sizes. Over the years, browser vendors have invented a variety of ways to allow developers to control how browsers lay out content, usually using a custom  tag.
  First among these was the HandheldFriendly tag, used initially by older Palm models as well as browsers like AvantGo, which has the format:

  This tag indicates to the browser that the page has been laid out by the developer to be viewable on a small screen, and that the browser should not attempt any further layout enhancements. While somewhat effective, it does not offer any granular control over the layout width – it’s just a true/false flag.
  Microsoft addressed this particular problem when it came up with the MobileOptimized tag for the PocketPC:

  The MobileOptimized tag allowed the developer to inform the mobile browser of the screen width that the page had been optimized for (in this case 320). While an improvement over the simpler HandheldFriendly tag, it still doesn’t offer much control over the layout, especially for devices that have different screen widths.
  Today, most modern mobile Web browsers use the Viewport  tag, which allows Web developers to give explicit instructions to a mobile browser regarding how a page should be laid out and respond to user manipulation. The Viewport tag has the format:

  The  Viewport tag provides the following settings to allow the developer more fine-tuned control over the content’s layout:
Viewport Property Width   width
  Sets the width of the viewport, in pixels, or the keyword “device-width”, which means whatever the width of the device screen is. The range is from 320 to 10,000.
  height
  Sets the height of the viewport, in pixels, or the keyword “device-height”. The range is from 480 to 10,000.
  user-scalable
  Indicates whether or not the user can scale the viewport, or in other words whether or not they can zoom in and out within content. Values can be “yes” or “no”. The default and recommended value is “yes”.
  initial-scale
  Sets the initial scale of the Viewport*. Allowable values are 0.1 to 10.0
  minimum-scale
  Sets the minimum allowable scale of the Viewport*. Allowable values are 0.1 to 10.0
  maximum-scale
  Sets the maximum allowable scale of the Viewport*. Allowable values are 0.1 to 10.0
  *Note: In the initial release, IE Mobile for Windows Phone 7 does not support initial-scale, maximum-scale, or minimum-scale.
How Windows Phone 7 Implements “device-width”
  The keyword “device-width” is intended to set the width of the Viewport to the width of the device that is viewing the page. On Windows Phone 7, the device width is 480 pixels. However, you will notice that if you set the Viewport width to “device-width”, IE actually sets the width to 320 (and also pins it to 320 if you specify a width of less than 320).
  Why does IE do this? We made this decision after a large amount of testing real-world mobile Web sites and learning (to our chagrin) that a very large number of sites out there that were using the “device-width” property were in fact not laid out for the device’s width, but were actually optimized for 320 pixels, probably because the majority of devices available on the market prior to Windows Phone 7 were 320 pixels wide. On many sites, this resulted in an empty strip along the side of the page when viewed in Windows Phone 7, since the sites were often using fixed-width 320px elements like  tags.
  Faced with the difficult decision of a) shipping a browser on which many common sites didn’t lay out optimally but was technically correct in using device-width, or b) making a slight adjustment to accommodate the many sites that didn’t use device-width properly, we decided to use 320 as the setting for device-width.
  In addition, if you use "device-width" and then rotate the screen to landscape, IE Mobile will re-size the Viewport to use the new dimensions. You can choose to re-layout your content by listening for the onResize event and then measuring the new width. For hard-coded numbers, IE Mobile simply scales up the content to fit the screen (which is what most other browsers do).
Default Viewport Widths
  Different phone manufacturers have different default widths for the Viewport. The following table lists the known defaults for the current crop of mobile browsers:
  Phone Browser
  Default Viewport Width
  Opera Mobile
  850 pixels
  iPhone Safari
  980 pixels
  Android
  800 pixels
  Windows Phone 7
  1024 pixels
  
Windows Phone 7 Support for META Tags
  IE in Windows Phone 7 will recognize all three of these meta tags, and will use the settings of the most modern tag that your page includes. IE will look for and use the settings in the following order:

  • HandheldFriendly
  • MobileOptimized (overrides HandheldFriendly)
  • Viewport (overrides both MobileOptimized and HandheldFriendly)
Summary
  The Viewport tag provides a de-facto standard way of exerting much better control over your content’s layout in today’s mobile browsers. Hopefully, this post has been helpful in illustrating how IE Mobile uses the Viewport and in making your Web sites look great on Windows Phone.
  Happy Coding!
  Joe Marini
Principal Program Manager, Windows Phone
Microsoft Corp.
joemarin@microsoft.com
http://twitter.com/joemarini
http://developer.windowsphone.com/
  
  原文地址:
  http://blogs.msdn.com/b/iemobile/archive/2010/11/22/the-ie-mobile-viewport-on-windows-phone-7.aspx   
  参考:
http://blogs.msdn.com/b/iemobile/archive/2011/01/21/managing-the-browser-viewport-in-windows-phone-7.aspx

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-66202-1-1.html 上篇帖子: Windows phone 7 31天学习笔记 11:加速器 下篇帖子: windows 7 如何关闭 程序崩溃时弹出的"windows正在检查该问题的解决方案"
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表