博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Web Design - The Viewport
阅读量:7209 次
发布时间:2019-06-29

本文共 1526 字,大约阅读时间需要 5 分钟。

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: 

       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();

转载地址:http://eqrum.baihongyu.com/

你可能感兴趣的文章
struts1——静态ActionForm与动态ActionForm
查看>>
Razor入门
查看>>
设计模式---装饰模式(Decorator)
查看>>
Ubuntu 16.04下轻量级文件搜索工具Catfish
查看>>
百度编辑器ueditor给上传的图片加入水印
查看>>
P2746 [USACO5.3]校园网Network of Schools
查看>>
项目构建之make工具
查看>>
Hadoop安装教程_单机/伪分布式配置
查看>>
浏览器拦截跨域请求处理方法
查看>>
[软件渲染器入门]五-平面着色和高氏着色
查看>>
【总结】设备树对platform平台设备驱动带来的变化(史上最强分析)【转】
查看>>
二进制(signed or unsigned)补码
查看>>
C# 委托
查看>>
正則表達式
查看>>
粗略。。。java设计模式总结。。。studying
查看>>
Java面试题集
查看>>
php截取中文字符串无乱码的方法
查看>>
adb server is out of date.killing的解决办法
查看>>
WebService工作原理及传输安全问题
查看>>
RobotFramework+Selenium2+Appium环境搭建
查看>>