返回顶部

收藏

处理移动端PPI过高问题

更多
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<meta id="aa" name="viewport" content="width=300,initial-scale=2.0,user-scalable=no,minimum-scale=1.0"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="apple-mobile-web-app-status-bar-style" content="black"/>
<meta content="telephone=no" name="format-detection" />
<title>PPI</title>
<script src="http://www.oschina.net/js/2012/jquery-1.7.1.min.js"></script>
</head>
<body style="overflow:hidden;padding:0;margin:0">
<script>
  function sizeReset(){
    var obj=$("<div style='font-size:12px;font-family:黑体'>正</div>");
    $("body").append(obj);
    var h=obj.height();
    var c1=1,c2;
    while(h==obj.height()){
      obj.text(obj.text()+"正");
      c1++;
    }
    c2=c1--;
    $("#aa").attr("content","width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0,target-densitydpi=device-dpi");
    if(h*2==obj.height()){
      return;
    }
    h=obj.height();
    while(h==obj.height()){
      obj.text(obj.text()+"正");
      c2++;
    }
    c2--;
    obj.css('font-size',c2/c1*12+"px");
  }
  $(document).ready(function(){
    sizeReset();
  });
</script>
</body>
</html>

标签:html

收藏

0人收藏

支持

0

反对

0

发表评论