What is The Viewport?

The viewport is the user's visible area of a web page.

The viewport varies with the device, and will be smaller on a mobile phone than on a computer screen.

Before tablets and mobile phones, web pages were designed only for computer screens, and it was common for web pages to have a static design and a fixed size.

Then, when we started surfing the internet using tablets and mobile phones, fixed size web pages were too large to fit the viewport. To fix this, browsers on those devices scaled down the entire web page to fit the screen.

This was not perfect!! But a quick fix.

LINK:http://www.w3schools.com/css/css_rwd_viewport.asp 

function init_viewport() {
           if (/Android (\d+\.\d+)/.test(navigator.userAgent)) {
               var version = parseFloat(RegExp.$1);
               if (version > 2.3) {
                   var width = window.outerWidth == 0 ? window.screen.width : window.outerWidth;
                   var phoneScale = parseInt(width) / 480;
                   document.write('<meta name="viewport" content="width=500, minimum-scale = ' + phoneScale + ', maximum-scale = ' + phoneScale + ', target-densitydpi=device-dpi">');
               }
               else {
                   document.write('<meta name="viewport" content="width=480, target-densitydpi=device-dpi">');
               }
           }
           else if (navigator.userAgent.indexOf('iPhone') != -1) {
               var phoneScale = parseInt(window.screen.width) / 480;
               document.write('<meta name="viewport" content="width=480; min-height=750;initial-scale=' + phoneScale + '; user-scalable=no;" /> ');         //0.75   0.82
           }
           else {
               document.write('<meta name="viewport" content="width=480, height=750, initial-scale=0.64" /> ');         //0.75   0.82
           }
       }
init_viewport();

Web Design - The Viewport的更多相关文章

  1. 自适应网页设计(Responsive Web Design)

    引用:http://www.ruanyifeng.com/blog/2012/05/responsive_web_design.html 随着3G的普及,越来越多的人使用手机上网. 移动设备正超过桌面 ...

  2. iPhone 6 Screen Size and Web Design Tips

    Apple updated its iPhone a bit ago making the form factor much bigger. The iPhone 6 screen size is b ...

  3. 自适应网页设计(Responsive Web Design)(转)

    随着3G的普及,越来越多的人使用手机上网. 移动设备正超过桌面设备,成为访问互联网的最常见终端.于是,网页设计师不得不面对一个难题:如何才能在不同大小的设备上呈现同样的网页? 手机的屏幕比较小,宽度通 ...

  4. (转)自适应网页设计(或称为响应式web设计)(Responsive Web Design)

    随着3G的普及,越来越多的人使用手机上网. 移动设备正超过桌面设备,成为访问互联网的最常见终端.于是,网页设计师不得不面对一个难题:如何才能在不同大小的设备上呈现同样的网页? 手机的屏幕比较小,宽度通 ...

  5. 转:15 Best Responsive Web Design Testing Tools

    Responsive Web Design is regarded as being the approach which suggests that web design and developme ...

  6. 自适应网页设计(Responsive Web Design)(转)

    作者: 阮一峰 出处:http://www.ruanyifeng.com/blog/2012/05/responsive_web_design.html 随着3G的普及,越来越多的人使用手机上网. 移 ...

  7. 阮一峰:自适应网页设计(Responsive Web Design)别名(响应式web设计)

    随着3G的普及,越来越多的人使用手机上网. 移动设备正超过桌面设备,成为访问互联网的最常见终端.于是,网页设计师不得不面对一个难题:如何才能在不同大小的设备上呈现同样的网页? 手机的屏幕比较小,宽度通 ...

  8. [转]如何设计自适应屏幕大小的网页 Responsive Web Design

    随着3G的普及,越来越多的人使用手机上网. 移动设备正超过桌面设备,成为访问互联网的最常见终端.于是,网页设计师不得不面对一个难题:如何才能在不同大小的设备上呈现同样的网页? 手机的屏幕比较小,宽度通 ...

  9. 自适应网页设计(Responsive Web Design)别名(响应式web设计)转载阮一峰

    随着3G的普及,越来越多的人使用手机上网. 移动设备正超过桌面设备,成为访问互联网的最常见终端.于是,网页设计师不得不面对一个难题:如何才能在不同大小的设备上呈现同样的网页? 手机的屏幕比较小,宽度通 ...

随机推荐

  1. Ubuntu: 为firefox安装flash插件

    下载对应的tar.gz包后,将里边的libflashplayer.so粘贴到/usr/lib/mozilla/plugins中后重启firefox即可.

  2. 应用框架的设计与实现——.NET平台(10 授权服务.CodeAccessSecurityAttribute)

    以下内容转载自:http://blog.csdn.net/dongma_yifei/article/details/1533124 CodeAccessSecurityAttribute 是 Prin ...

  3. SpringMVC实现一个controller写多个方法

    MultiActionController与ParameterMethodNameResolver在一个Controller类中定义多个方法,并根据使用者的请求来执行当中的某个方法,相当于Struts ...

  4. MySQL的pt-query-digest的下载与使用

    对于脚本文件,是可以执行的,我们不用安装.所以,但是这个脚本文件没有执行的权限,所以,我们首先赋予这个脚本文件的可执行的权限. 再次查看文件的信息后. 已经有了执行的权限了. 运行脚本的时候,可要注意 ...

  5. EditPlus不能着色显示SQl语句的问题

    说明:今天重装了系统后,从网上安装下载了一个EditPlus阅读代码,发现sql语句是灰色的,不和以前的带有颜色的看着美观了,顿时心里别扭了起来.以为下错了版本,可是换了好几个,都是这样,网上查了一下 ...

  6. Bootstrap3生成响应式的特价商品展示布局

    在线演示 本地下载 在线前端调试地址,大家可以在线自己调试. 在线调试唯一地址:http://www.gbtags.com/gb/debug/fa35e396-0a04-4b73-9bfc-c6334 ...

  7. JAVA学习中Swing概述中的JFrame学习

    package com.swing; import java.awt.Color;import java.awt.Container;import java.awt.event.WindowAdapt ...

  8. SSL在https和MySQL中的原理思考

    之前对HTTPS通信过程有过了解,HTTPS是应用HTTP协议使用SSL加密的版本,在TCP和HTTP之间增加SSL协议.通过握手阶段认证双方身份,协商对称秘钥对通信信息进行加密.此处只描述常用的服务 ...

  9. MyEclipse8.6中提交SVN报错

    上周五(11月27日)的时候,从TortoiseSVN提交项目报错,然后直接从MyEclipse中检出来,修改后提交同样报错. MyEclipse8.6中提交SVN报错,错误提示如下: commit ...

  10. 删除配置文件解决OS X各种WiFi无法连接的顽固问题,解决MAC无法连接wif的情况 Preferences

    删除配置文件解决OS X各种WiFi无法连接的顽固问题 删除配置文件解决OS X各种WiFi无法连接的顽固问题1 记住现在wifi的密码并将wifi关闭2 前往文件夹/Library/Preferen ...