zoukankan      html  css  js  c++  java
  • Web Design

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

  • 相关阅读:
    使用NUnit做单元测试(总结版)
    http、ajax调试利器:Fiddler!!!(资料汇总)
    驳《从团购网站看中国人的创新精神》
    破解迷团:在asp.net  2.0服务器上运行.net 3.5(一)
    扩充NetCMS的功能:添加{TM:Repeater}{/TM:Repeater}标签
    TFS 2010 基础配置手动升级到高级配置 安装实践
    .net 中的 StringBuilder 和 TextWriter 区别
    最大团问题
    全排列问题
    ado.net连接池
  • 原文地址:https://www.cnblogs.com/xiaokang088/p/5649045.html
Copyright © 2011-2022 走看看